static String hsl2hex(int h, int s, int l) { return hsl2hex(new int[]{h, s, l}); }
private void handleColorSelection(MouseEvent event, Button button, Input input) { final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(closedEvent -> { if (!closedEvent.isCanceled()) { int[] rgb = ColorUtils.getRGB(dlg.getColor()); String color = "#" + dlg.getColor(); input.setValue("rgb("+rgb[0]+","+rgb[1]+","+rgb[2]+");"); } }); dlg.showRelativeTo(ElementWrapperWidget.getWidget(button)); dlg.getElement().getStyle().setBackgroundColor("white"); }
static String rgb2hex(int r, int g, int b) { return rgb2hex(new int[]{r, g, b}); }
private void handleColorSelection(MouseEvent event, Button button, Input input) { final ColorPickerDialog dlg = new ColorPickerDialog(); dlg.getElement().getStyle().setZIndex(9999); dlg.addDialogClosedHandler(closedEvent -> { if (!closedEvent.isCanceled()) { int[] rgb = ColorUtils.getRGB(dlg.getColor()); String color = "#" + dlg.getColor(); input.setValue("rgb("+rgb[0]+","+rgb[1]+","+rgb[2]+");"); } }); dlg.showRelativeTo(ElementWrapperWidget.getWidget(button)); dlg.getElement().getStyle().setBackgroundColor("white"); }
static String rgb2hex(int r, int g, int b) { return rgb2hex(new int[]{r, g, b}); }
static String hsl2hex(int h, int s, int l) { return hsl2hex(new int[]{h, s, l}); }
private String getColorAtPixel(int x, int y) { x = Math.max(Math.min(x, 179), 0); y = Math.max(Math.min(y, 179), 0); RenderingContext ctx = canvas.getContext(); ImageData imageData = ctx.getImageData(x, y, 1, 1); JsArrayInteger data = imageData.getData(); return ColorUtils.rgb2hex(data.get(0), data.get(1), data.get(2)); }
public void setColor(String color) { int[] rgb = ColorUtils.getRGB(color); int[] hsl = ColorUtils.rgb2hsl(rgb); hue = hsl[0]; handleX = (int) Math.min(Math.max(Math.round(hsl[1] * 180d / 100d), 0), 179); handleY = (int) Math.min(Math.max(Math.round(hsl[2] * 180d / 100d), 0), 179); drawGradient(true); fireColorChanged(color); } }
private String getColorAtPixel(int x, int y) { x = Math.max(Math.min(x, 179), 0); y = Math.max(Math.min(y, 179), 0); RenderingContext ctx = canvas.getContext(); ImageData imageData = ctx.getImageData(x, y, 1, 1); JsArrayInteger data = imageData.getData(); return ColorUtils.rgb2hex(data.get(0), data.get(1), data.get(2)); }
public void setColor(String color) { int[] rgb = ColorUtils.getRGB(color); int[] hsl = ColorUtils.rgb2hsl(rgb); hue = hsl[0]; handleX = (int) Math.min(Math.max(Math.round(hsl[1] * 180d / 100d), 0), 179); handleY = (int) Math.min(Math.max(Math.round(hsl[2] * 180d / 100d), 0), 179); drawGradient(true); fireColorChanged(color); } }
180); for (int y = 0; y <= 179; y++) { String hex = ColorUtils.hsl2hex(y * 2, 100, 100);
180); for (int y = 0; y <= 179; y++) { String hex = ColorUtils.hsl2hex(y * 2, 100, 100);