Vertex adding inside for-loop?
in
Core Library Questions
•
1 year ago
I need to add vertexes based on array values, so i loop through the array always adding the vertex with the value from the array, but somehow it doesnt seem to work (shape doesnt get drawn)... what's wrong with this simple piece of code? Any help GREATLY appreciated...
- import processing.opengl.*;
- ArrayList values;
- void setup() {
- size(500, 500, OPENGL);
- smooth();
- values = new ArrayList();
- values.add(2);
- values.add(4);
- values.add(4);
- values.add(5);
- values.add(4);
- values.add(4);
- drawGraph();
- }
- void drawGraph() {
- background(255);
- fill(20, 60, 180, 75);
- stroke(20, 60, 180, 75);
- translate(width/2, height/2);
- beginShape();
- for (int i = 0; i <= values.size() - 1; i++) {
- int tmpValue = (Integer) values.get(i);
- line(0, 0, 0, -40 * tmpValue);
- vertex(0, -40 * tmpValue);
- rotate(radians(360/values.size()));
- }
- endShape(CLOSE);
- }
1