Triangle Strip

Triangle Strip by Ira Greenberg.

Generate a closed ring using the vertex() function and beginShape(TRIANGLE_STRIP) mode. The outsideRadius and insideRadius variables control ringâ€™s radii respectively.

```
int x;
int y;

void setup() {
size(640, 360);
background(204);
x = width/2;
y = height/2;
}

void draw() {
background(204);

int numPoints = int(map(mouseX, 0, width, 6, 60));
float angle = 0;
float angleStep = 180.0/numPoints;

beginShape(TRIANGLE_STRIP);
for (int i = 0; i <= numPoints; i++) {
angle += angleStep;
vertex(px, py);
vertex(px, py);
angle += angleStep;
}
endShape();
}

```

Functions Used

size()

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

vertex()

All shapes are constructed by connecting a series of vertices

sin()

Calculates the sine of an angle

beginShape()

Using the beginShape() and endShape() functions allow creating more complex forms

int

Datatype for integers, numbers without a decimal point

setup()

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

map()

Re-maps a number from one range to another

cos()

Calculates the cosine of an angle

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

Converts a degree measurement to its corresponding value in radians