Is there an easier way to get the updated Pixels

I want to get the pixels that were updated in code between a and b without comparing loadPixels () at a with loadPixels() at b. Is that possible? (-> and how is that possible?)

1 Like

I can think of three options.

  • create a PGraphics object, copy original pixels to PGraphics and do changes there. Then compare it to original pixels.
  • create empty (black) PGraphics and do same changes as you do to pixels. You’ll at least know what pixels changed and to what
  • save pixels to files and then compare them
1 Like

thank you but the problem is:
If I draw something with the same color as the background (black if ampty PGraphics) the changes will not be detected. I need this to save complex structures of rectangles/ellipses/… (so I don’t have to recalculate them). Is there an other way to save structures without losses?

If there is no other way, I will use a map<Integer, Integer> (index, value) to save the changes and I will recognize the changes with 2 different backgrounds, but this is not a good code …

I agree it doesn’t sound to be a good solution. Because I have only a vague understanding what you are doing, I can only give very generic advice. So could you elaborate a bit what you are doing?

My experience is that if things get tricky and complicated then you are doing it wrong way.

1 Like

https://www.processing.org/tutorials/pshape/

-groups-
Thats what i wanted…

3 Likes

Glad that you found a solution with PShape groups that worked for you.

For this – PGraphics can be created ARGB with an alpha (transparent) background. Anything drawn would be detectable as a change, including black.