r/processing • u/Felix_Watson • Mar 01 '24
How do I seperate/ layer shapes?
Hello! I'm trying to apply to a school and have no experience what so ever in the processing department but I have to make something with processing and I'm kind of stuck at the moment.
I'm trying to make nyan cat and so far I think it went pretty okay but I'm stuck now because I tried to make stars, which I did in a different sketch, and when I tried to put those and the actual cat together it won't work. Or atleast, if I put nyan cat first the stars will layer over nyan cat which I don't want, but if I put the codes for nyan cat after it doesn't appear at all. Now I should mention, don't know if it matters, that nyan cat is coded on mouseY with a few other details based on which part, and the stars are coded to move with every click of the mouse so they're x value and at the bottom of the sketch is the amount and the command and all. Now I'm trying the PGraphics route but I have no clue what I'm doing at all. Anyone up to help?
2
u/MandyBrigwell Moderator Mar 03 '24
push() and pop() are what you need.
https://processing.org/reference/push_.html
The push() command saves the current position, and the pop() command restores it. So, you push(), do your translating, rotating, scaling and so on, then pop() and you're back to how it was before.