## Generate a spiral

The following example generates a spiral.
This code example is worth studying for several reasons:

• It demonstrates the trigonometric math used to generate circles, namely sin(), cos()
• It illustrates the use of the radians() function, which converts an angular measurement in degrees to an angular measurement in radians (which is required for sin() and cos()).
• It illustrates that circle-generating math can be used for something other than “just” circles.
• It demonstrates a way of using beginShape()/endShape() with a for{} loop, in order to computationally generate and render a series of points.
```// GENERATE A SPIRAL   size(300,300); background(255);   float centerX = width/2; float centerY = height/2; float radius = 0;   float nLoops = 3; float nDegreesPerLoop = 360; float nDegreesTotal = nLoops * nDegreesPerLoop;   noFill(); beginShape();   for (float angleDeg=0; angleDeg<nDegreesTotal; angleDeg++){ float angleRad = radians(angleDeg); // the radians version of that angle float x = centerX + radius * cos(angleRad); float y = centerY + radius * sin(angleRad); vertex(x,y); radius += 0.1; // increase the radius for each point! } endShape();```