Example usage for com.google.gwt.canvas.dom.client ImageData getGreenAt

List of usage examples for com.google.gwt.canvas.dom.client ImageData getGreenAt

Introduction

In this page you can find the example usage for com.google.gwt.canvas.dom.client ImageData getGreenAt.

Prototype

public final int getGreenAt(int x, int y) 

Source Link

Document

Returns the green value at position (x,y).

Usage

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setColour(int x, int y, Canvas targetCanvas, VerticalPanel targetPanel) {
    x = (x >= targetCanvas.getCoordinateSpaceWidth()) ? targetCanvas.getCoordinateSpaceWidth() - 1 : x;
    y = (y >= targetCanvas.getCoordinateSpaceHeight()) ? targetCanvas.getCoordinateSpaceHeight() - 1 : y;
    final ImageData imageData = targetCanvas.getContext2d().getImageData(x, y, 1, 1);
    final int blue = imageData.getBlueAt(0, 0);
    final int green = imageData.getGreenAt(0, 0);
    final int red = imageData.getRedAt(0, 0);
    if (targetPanel.equals(selectedColourPanel)) {
        selectedColourData = new ColourData(red, green, blue);
    }/*from   w w  w. j ava  2 s . c  o m*/
    targetPanel.getElement().setAttribute("style", "background:rgb(" + red + "," + green + "," + blue + ")");
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setHue(int x, int y, Canvas targetCanvas) {
    x = (x >= targetCanvas.getCoordinateSpaceWidth()) ? targetCanvas.getCoordinateSpaceWidth() - 1 : x;
    y = (y >= targetCanvas.getCoordinateSpaceHeight()) ? targetCanvas.getCoordinateSpaceHeight() - 1 : y;
    final ImageData imageData = targetCanvas.getContext2d().getImageData(x, y, 1, 1);
    final int blue = imageData.getBlueAt(0, 0);
    final int green = imageData.getGreenAt(0, 0);
    final int red = imageData.getRedAt(0, 0);
    setHue(red, green, blue);/* w w  w.ja v  a2  s.c o  m*/
}