Hi,
thank you very much for the code!! That seems to be exactly what I was looking for :-))
I thing that concept of ‘old school’ way of drawing (I explained that in my reply to tabreturn) is very important and really should be among the basic Processing tutorials. For example, here is why I need to draw from outside of the draw()
loop:
A while ago I was testing a hardware device prototype of 3D printer consisting of stepper motors and electrovalves. For prototyping I used Rasbperry Pi (I will later probably use microcontrollers) running Python. Since the hardware is quite big and heavy I can’t develop the algorithms at home so I thought I might develop a visualization of how the device works to be able to test the code even at home when I can’t test it on a real hardware.
I did manage to simulate 80% of the device by changing the code so it could be called from the draw()
loop but for that I had to make quite a lot of changes into the original code and the rest was just to complicated to adapt for calling from within the draw()
loop.
Let me now see if I understand how the code you posted work:
The first thing I am unable to find the documentation about is PImage.ALPHA_MASK
. I have a feeling the Processing documentation is missing some essential data. For example it took me a while to realize I can use certain methods not only with the display window but with the PGraphics
too. When I was reading the documentation of the filter()
I read:
Filters the display window using a preset filter or with a custom shader.
But later I saw in some forum posts even:
pg = createGraphics(40, 40);
pg.filter()
works well. I tried to find the documentation about that but couldn’t find any :-/
Nevertheless, I am not sure how exactly is:
ALL_COLORS = PImage.ALPHA_MASK
here used to get the colors.
Next, you are running the new thread waiting for the pg
to become valid before entering the draw()
loop where it is used and in the pg_thread()
you create PGraphics
object, calculate width/2 and height/2 (is bit shift faster), drawing the intermediate state and invoking the delay()
.
Although I understand the basic concept, I would appreciatte if you could explain me a few details:
The first thing is - what is the purpose of pgt
? Why couldn’t you use just pg
? The same for interval
and all_colors
- why:
interval, all_colors = INTERVAL, ALL_COLORS
I didn’t know the draw()
could have arguments.
I wouldn’t expect
with pgt.beginDraw():
could be used to avoid typing pgt.endDraw()
. But as you might guess, I am comming from the embedded world (read C and assembler)
BTW, can you tell why the code I linked in the first post doesn’t work? I mean the code in the before the last post in this thread.
Concluding from the very last post in that thread the code should work but it doesn’t.
Thank you again for the reply! I can see from the structure of your code you do know what you are doing
Regards