drawing a vertex from an array
in
Programming Questions
•
2 years ago
I have a rather simple question. Unfortunately I cannot manage to get it myself.
Below is the simplified code of a sketch I have.
I would like to draw a shape from an array. So far so good.
But why can't I fill the shape and close it?
What am I doing wrong?
I tried this with both vertex and line.
Any help would be appreciated!
- float[] coordinatesX = {
- 30,85,85,30
- };
- float[] coordinatesY = {
- 20,20,75,75
- };
- void setup() {
- size(800,800);
- smooth();
- background(255);
- }
- void draw() {
- stroke(0);
- fill(0);
- for (int i = 0; i < coordinatesX.length-1; i++) {
- for (int j = 0; j < coordinatesY.length-1; j++) {
- beginShape();
- vertex(coordinatesX[i],coordinatesY[i]);
- vertex(coordinatesX[i+1],coordinatesY[i+1]);
- endShape(CLOSE);
- }
- }
- }
1