Facebook
From Adjowa Asamoah, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 173
  1. float[] dailyTemperatures = {20, 22, 23, 25, 24, 22, 21, 20, 19, 18, 17, 16, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 30};
  2. int numDays = dailyTemperatures.length;
  3.  
  4. void setup() {
  5.   size(800, 800);
  6.   background(255);
  7.   smooth();
  8.  
  9.   // Center of the canvas
  10.   float centerX = width / 2;
  11.   float centerY = height / 2;
  12.  
  13.   // Draw swirling curves representing temperature variations
  14.   translate(centerX, centerY);
  15.   float angleIncrement = TWO_PI / numDays;
  16.   for (int i = 0; i < numDays; i++) {
  17.     float radius = map(dailyTemperatures[i], 15, 30, 100, 300);
  18.     float angle = i * angleIncrement;
  19.     float x = cos(angle) * radius;
  20.     float y = sin(angle) * radius;
  21.     float nextX = cos((i + 1) * angleIncrement) * radius;
  22.     float nextY = sin((i + 1) * angleIncrement) * radius;
  23.      float c / 2;
  24.      float c / 2;
  25.      float c / 2;
  26.      float c / 2;
  27.     noFill();
  28.     stroke(0);
  29.     strokeWeight(2);
  30.     bezier(0, 0, controlX1, controlY1, controlX2, controlY2, nextX, nextY);
  31.   }
  32. }
  33.