Very Basic createShape() Question
in
Programming Questions
•
26 days ago
Hi, I was just curious about 2 things regarding the following code.
1. Why is there a brief interval of time from when the program starts to when the shape is drawn in which there is just a
white background? In other words, why doesn't the program start with the shape already drawn? I tried moving
shape(tpz, 0, 0); to the setup function but this doesn't work, presumably for very obvious reasons beyond my comprehension.
2. Why is there a momentary flicker of gray in the instant that the shape is drawn?
Here is the code
PShape tpz; // The PShape object
void setup() {
size(400, 400, P2D);
// Create custom shape by specifying vertices.
tpz = createShape();
tpz.beginShape();
tpz.fill(255, 0, 0);
tpz.noStroke();
tpz.vertex(150,150);
tpz.vertex(250,150);
tpz.vertex(300,250);
tpz.vertex(100,250);
tpz.endShape(CLOSE);
}
void draw() {
background(255);
shape(tpz, 0, 0);
}
Thanks in advance for the help!
1