triangle-fan is not displaying

Hey coders,

i am trying to draw a triangle-fan, but anyway it is not displaying. Could someone have a look?

Many thanks!

int segmentCount = 6;
int radius = width/2;

float angleStep = 360/segmentCount;

color black = #222222;
color white = #eeeeee;
color red = #E14C45;

void setup() {
  size(300, 300);
}

void draw() {
  background(white); 
  fill(red);
  stroke(black);
  beginShape(TRIANGLE_FAN);
  vertex(width/2, height/2);
  for (float angle=0; angle<=360; angle = angle + angleStep) {
    float vx = width/2 + cos(radians(angle))*radius;
    float vy = height/2 + sin(radians(angle))*radius;
    vertex(vx, vy);
  }
  endShape();

}

This is what i've expected.

Answers

Sign In or Register to comment.