パウルクレーの色彩円環

『教育スケッチブック』Fig.87をモチーフに作図

void setup()
{
  size(320, 460);
  colorMode(HSB,360,100,100);
  background(#FFFFFF);
  fig86();
  translate(-width/2, -height/2);
  fig87();
}

void fig86()
{
  strokeWeight(2);
  smooth();
  translate(width/2, height/2);
  for(float h=0; h < 360; h+=0.25){
    float s = 99;
    float b = 99;
    for(int r=79; r > 0; r--){
      float a = r / 79.0 * 90.0;
      b = 99.0 * sin(radians(a));
      float ch = h;
      if(h < 120){
        ch = h / 2;
      } else if(h < 180){
        ch = h - 60; 
      } else if(h < 240){
        ch = 120 + (h - 180)* 2;
      } else {
        ch = h;
      }
      color c = color(ch, s, b);
      float x = r*cos(radians(h-60.0)) + width / 2;
      float y = r*sin(radians(h-60.0)) + height / 2;
      set((int)x, (int)y, c);
    }
  }

  stroke(0,0,100,128);
  for(int i = 0; i < 6; i++){
      line(0,0,80*cos(radians(60*i)),80*sin(radians(60*i)));
  }
  noFill();
  stroke(#ffffff);
  ellipse(0, 0, 160.0, 160.0);
}

void fig87()
{
  stroke(#000000);
  smooth();
  translate(width/2, height/2);
  fill(#666666);
  ellipse(0,0,30,30);
  int s = 99;
  int b = 99;
  for(int i=0; i < 6; i++){
    switch(i){
      case 0:
        fill(29,s,b);  // ORANGE
        break;
      case 1:
        fill(59,s,b);  // YELLOW
        break;
      case 2:
        fill(119,s,b);  // GREEN
        break;
      case 3:
        fill(239,s,b);  // BLUE
        break;
      case 4:
        fill(299,s,b);  // VIOLET
        break;
      case 5:
        fill(0,s,b);  // RED
        break;      
    }
    ellipse(80*cos(radians(60*i)),80*sin(radians(60*i)),60,60);
    line(0,0,50*cos(radians(60*i)),50*sin(radians(60*i)));
  }
  noFill();
  ellipse(0,0,160,160);
}