Radial Gradient.

Radial Gradient.

Draws a series of concentric circles to create a gradient from one color to another.


int dim;

void setup() {
  size(640, 360);
  dim = width/2;
  background(0);
  colorMode(HSB, 360, 100, 100);
  noStroke();
  ellipseMode(RADIUS);
  frameRate(1);
}

void draw() {
  background(0);
  for (int x = 0; x <= width; x+=dim) {
    drawGradient(x, height/2);
  } 
}

void drawGradient(float x, float y) {
  int radius = dim/2;
  float h = random(0, 360);
  for (int r = radius; r > 0; --r) {
    fill(h, 90, 90);
    ellipse(x, y, r, r);
    h = (h + 1) % 360;
  }
}

Functions Used

fill()

Sets the color used to fill shapes

Learn More
size()

Defines the dimension of the display window width and height in units of pixels

Learn More
ellipse()

Draws an ellipse (oval) to the screen

Learn More
setup()

The setup() function is run once, when the program starts

Learn More
frameRate

The system variable frameRate contains the approximate frame rate of a running sketch

Learn More
random()

Generates random numbers

Learn More
colorMode()

Changes the way Processing interprets color data

Learn More
draw()

Called directly after setup(), the draw() function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called

Learn More
noStroke()

Disables drawing the stroke (outline)

Learn More
ellipseMode()

Modifies the location from which ellipses are drawn by changing the way in which parameters given to ellipse() are intepreted

Learn More
background()

The background() function sets the color used for the background of the Processing window

Learn More