We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have a simple code drawing multiple shapes with various colors, sizes and thicknesses. Oddly, a fill line with one color combination, or a translation line with one set of points, is effecting other colors and translation points. For example, at the beginning of my code, I have a white circle, and towards the end have a red line. Yet for some reason, the white head is outlined in red. Is there a way I can prevent that? And is there a way I can "section" off each shape so that their characteristics are determined individualy rather than by the other aspects from different shapes.
Thanks, G
Answers
You can enclose your drawings between calls to pushStyle() and popStyle(), but really you should be setting the fill and stroke colors correctly before drawing each of your shapes. The settings will persist until you change them!
My code (that you need to see) is like this-
void draw() { background(0, 0, 0); fill(255, 255, 255); ellipse(250, 100, 75, 75);
strokeWeight(3); stroke(255, 255, 255); line(250, 136, 250, 300);
strokeWeight(3); translate(250, 300); stroke(255, 0, 0); rotate(radians(angle + 180)); line(0, 0, 0, 100); }
Yet the ellipse is outlined in red
TfGuy44, There is a space between line 7 and 8. And the next shape also includes a translation however when it translates, it just adds to the previous translation. How do I fix that?
A space? So what? White space doesn't matter.
I think you're confused about how fill/stroke colors and translations work.
Ok, imagine you are going to paint a picture. Your paintbrush is magic, because it draws shapes. You say, "Hey paintbrush, I want the next shape I draw to be filled with white and have a blue outline."
Now you draw a shape. "Hey paintbrush, draw a circle."
Now you say "Hey paintbrush, I want the next shape to be filled with red!"
"Another circle!"
Whoa, wait, what? Why is that circle ALSO outlined in blue? It's because the paintbrush remembers the last colors you told it to use. (Even between finishing painting one picture (the end of draw()) and starting the next (draw() running again).
What you need to do is make sure that, before you draw any shape, you set both the fill color and the stroke color, or disable them with noStroke() and noFill().
As for translations, they add together too.
No worries I found the problem, needed pushMatrix() and popMatrix()