i wanted to be the “smartass” and suggest that it might be good if we can check
on the shape we created ( like print its vertexes )
like you could find that you made a shape ( and closed and fill it )
BUT all at / the same / one point
well i just found that that is indeed possible,
but i needed to create a (named) shape
and it shows that the vectors are pure, not contain the translate or rotate…
test v03
// https://discourse.processing.org/t/vertex-will-not-fill-processing-3/6013
// v02 vertex as shape
// v03 diagnostic vertex
PShape s;
boolean dbug = true; // use: if ( dbug ) println("");
boolean rottest = true;
void setup() {
size(500, 500);
vertexCircle(width/2, height/2, 100, 30, 120, 5); // now creates shape s AND shows it
}
void draw() {
}
void vertexCircle(int x, int y, int diameter, int arcStrt, int arcStp, int arcPntAmt) {
float anglestep = radians ((arcStp-arcStrt)/float(arcPntAmt));
if ( dbug ) println("angle: "+anglestep);
fill(0, 200, 0);
stroke(200, 0, 0);
pushMatrix();
translate(x, y);
rotate (radians(arcStrt));
s = createShape();
s.beginShape();
s.vertex(0, 0);
for (int i = 0; i <= arcPntAmt; i++) {
float posx = diameter*cos(i*anglestep);
float posy = diameter*sin(i*anglestep);
if ( dbug ) println("point: x: "+posx+" y: "+posy);
s.vertex(posx, posy); // vertex needs absolut positions
if ( dbug ) println("i "+i);
if (rottest) {
rotate(anglestep); // still can use relative positioning
ellipse(0, diameter+10, 3, 3);
line(0, diameter, 0, diameter+10); // to show something
}
}
s.vertex(0, 0);
s.endShape();
// v 03 try readback shape
if ( dbug ) println(" check vertex content");
for (int i=0; i < s.getVertexCount(); i++) {
if ( dbug ) println("vx: "+s.getVertex(i).x+" vy: "+s.getVertex(i).y);
}
shape(s,0,0);
popMatrix();
}
now use that trick on your code:
( still shows no shape, but prints out WHY )
PShape s;
void setup() {
size(800, 600);
fill(50, 100, 150);
s = createShape();
s.beginShape(POINTS);
vertexCircle(width/2, height/2, 100, 0, 360, 360);
s.endShape(CLOSE);
shape(s, 0, 0);
println(" check vertex content");
for (int i=0; i < s.getVertexCount(); i++) {
println("vx: "+s.getVertex(i).x+" vy: "+s.getVertex(i).y);
}
}
void draw() {
}
void vertexCircle(int x, int y, int diameter, int arcStrt, int arcStp, int arcPntAmt) {
pushMatrix();
translate(x, y);
rotate (arcStrt);
for (int vertexAmt = 0; vertexAmt <= arcPntAmt; vertexAmt += 1) {
s.vertex(0, 0 + diameter);
rotate ( radians (360-arcStp/arcPntAmt));
}
popMatrix();
}