private float[] toHSB(FlatColor color) {

    java.awt.Color col =
        new java.awt.Color(
            (float) color.getRed(), (float) color.getGreen(), (float) color.getBlue(), 1.0f);
    float[] comps = java.awt.Color.RGBtoHSB(col.getRed(), col.getGreen(), col.getBlue(), null);
    return comps;
  }
  @Override
  public void draw(GFX gfx) {
    float[] curr = toHSB(color);
    float[] start = toHSB(startColor);

    // hue, vertical
    gfx.translate(centerPoint.getX(), centerPoint.getY());
    for (double i = 0; i < 200; i++) {
      FlatColor c = FlatColor.hsb(i / 200 * 360.0, curr[1], curr[2]);
      gfx.setPaint(c);
      double y = start[0] * 200;
      gfx.drawLine(-5, i - y, +5, i - y);
    }
    gfx.translate(-centerPoint.getX(), -centerPoint.getY());

    // saturation, 30 degrees
    gfx.translate(centerPoint.getX(), centerPoint.getY());
    for (double i = 0; i < 200; i++) {
      FlatColor c = FlatColor.hsb(curr[0] * 360, i / 200.0, curr[2]);
      gfx.setPaint(c);
      double sin = Math.sin(Math.toRadians(30));
      double cos = Math.cos(Math.toRadians(30));
      double x = cos * i - cos * start[1] * 200 + 0;
      double y = sin * i - sin * start[1] * 200 + 0;
      // tx = cos(30)*i
      // tx/cos(30) = i
      gfx.drawLine(x, y - 5, x, y + 5);
    }
    gfx.translate(-centerPoint.getX(), -centerPoint.getY());

    // brightness, 150 degrees
    gfx.translate(centerPoint.getX(), centerPoint.getY());
    for (double i = 0; i < 200; i++) {
      FlatColor c = FlatColor.hsb(curr[0] * 360, curr[1], i / 200.0);
      gfx.setPaint(c);
      double sin = Math.sin(Math.toRadians(150));
      double cos = Math.cos(Math.toRadians(150));
      double x = cos * i - cos * start[2] * 200;
      double y = sin * i - sin * start[2] * 200;
      gfx.drawLine(x, y - 5, x, y + 5);
    }
    gfx.translate(-centerPoint.getX(), -centerPoint.getY());

    gfx.setPaint(color);
    double s = 16;
    gfx.fillOval(centerPoint.getX() - s / 2, centerPoint.getY() - s / 2, s, s);
    gfx.setPaint(FlatColor.BLACK);
    gfx.drawOval(centerPoint.getX() - s / 2, centerPoint.getY() - s / 2, s, s);
    gfx.drawRect(0, 0, getWidth(), getHeight());
  }
 private String valueToString(Object value) {
   if (value instanceof String) {
     return '"' + ((String) value) + '"';
   }
   if (value instanceof FlatColor) {
     FlatColor fc = (FlatColor) value;
     return '"' + "#" + Integer.toHexString(fc.getRGBA()).substring(2) + '"';
   }
   if (value instanceof List) {
     StringBuffer sb = new StringBuffer();
     sb.append("[");
     boolean first = true;
     for (Object o : ((List) value)) {
       if (!first) sb.append(",");
       sb.append('"' + o.toString() + '"');
       first = false;
     }
     sb.append("]");
     return sb.toString();
   }
   if (value == null) return "null";
   return value.toString();
 }