/** * @param _h * @param _s * @param _b * @param _a */ public void setHSB(float _h, float _s, float _b, float _a) { _h = UFloat.range(_h, 0.0f, 1.0f); _s = UFloat.range(_s, 0.0f, 1.0f); _b = UFloat.range(_b, 0.0f, 1.0f); AColor color = new AColor(_h, _s, _b); color.setA(_a); value.setValue(color); }
@Override public void paintBackground(ICanvas g, int _x, int _y, int _w, int _h) { float _hue = h(); float _s = s(); float _b = b(); IImage _buffer = buffer; if (compareValue == null || compareValue != value.getValue()) { compareValue = value.getValue(); _buffer = VS.systemImage((int) _w, (int) _h, VS.c32BitARGB); buffer = _buffer; ICanvas bg = _buffer.canvas(g.who()); int x = _x + 0; int y = _y + 15; for (float s = 0.0f; s < 1.0f; s += 1.0f / w) { for (float b = 1.0f; b > 0.0f; b -= 1.0f / h) { bg.setColor(new AColor(AColor.HSBtoRGB(_hue, s, b))); bg.line(x, y, x, y); y++; } y = 15; x++; } y = 1; x = 0; for (float hue = 0.0f; hue < 1.0f; hue += 1.0f / w) { bg.setColor(new AColor(AColor.HSBtoRGB(hue, 1.0f, 1.0f))); bg.rect(true, x, y, 10, 10); x++; } bg.dispose(); } if (_buffer != null) { g.drawImage(_buffer, 0, 0, null); g.setColor(new AColor(AColor.HSBtoRGB(_hue, 1 - _s, 1.0f))); g.oval(false, (int) (w * _s) - 3, 15 + (int) ((h - 15) * (1 - _b)) - 3, 7, 7); g.line((int) (w * _hue), 0, (int) (w * _hue), 10); } }
/** @return */ public float a() { return ((AColor) value.getValue()).getAlpha(); }
/** @return */ public float b() { return ((AColor) value.getValue()).getBrightness(); }
/** @return */ public float s() { return ((AColor) value.getValue()).getSaturation(); }
/** @return */ public float h() { return ((AColor) value.getValue()).getHue(); }