Ejemplo n.º 1
0
  public static ColorScale createCyclicScale(int count) {
    ColorScale sc = new ColorScale();
    //                    red   yellow  green   blue    red
    int[] h = new int[] {0, 59, 127, 244, 360};
    int[] s = new int[] {100, 84, 99, 100};
    int[] b = new int[] {90, 93, 74, 83};

    sc.colors = new Color[count];
    for (int i = 0; i < sc.colors.length; i++) {

      float angle = 4 - i / 256f * 4;
      int quadrant = (int) angle;
      angle -= quadrant;
      quadrant = Utils.mod(quadrant + 1, 4);

      float vh = h[quadrant] * w(angle) + h[quadrant + 1] * (1 - w(angle));
      float vs = s[quadrant] * w(angle) + s[Utils.mod(quadrant + 1, 4)] * (1 - w(angle));
      float vb = b[quadrant] * w(angle) + b[Utils.mod(quadrant + 1, 4)] * (1 - w(angle));

      sc.colors[i] = Color.getHSBColor(vh / 360f, vs / 100f, vb / 100f);
    }
    sc.setRange(0, 2 * Math.PI);
    sc.addBounds();
    return sc;
  }
Ejemplo n.º 2
0
 public static ColorScale createHSBScale(int count) {
   ColorScale sc = new ColorScale();
   sc.colors = new Color[count];
   for (int i = 0; i < count; i++) {
     sc.colors[i] = Color.getHSBColor(i / 300.0f, 1, 1);
   }
   sc.setRange(0, 255);
   sc.addBounds();
   return sc;
 }