This is one of my first scripts using animation. I lay out the background elements in setup(). This is a picture of sky, moon, ocean, and foreground. These elements never change.
Using draw() I move a barge with blinking light across the horizon and I also have a cloud moving across the sky.
Question - how to I restore the background after the barge (and the cloud) has changed position. I'm looking for the most elegant/practical/general way. I guess I'm looking for a function or procedure that redraws the whole static background before each new update of the barge and cloud elements.
I guess I could redo the whole generation of the background in draw(), but I'm sure there's a much better way.
Code is below. Note that a substantial part of the code in the setup() section has been commented out. This code simply generated static snowflakes in the scene.
How does one insert an execution delay into a sketch? (not a pause ,but a delay); For example, I've got a sketch to generate a fractal tree. It works fine, but I'd like to be able to slow up the execution by introducing a slight delay after each branch of the tree is generated so that I can view the process of tree generation. As it is now, the full tree appears almost instantaneously. Thanks.
How do I fill a closed area which I've formed myself? I.e., not filling a predefined Processing shape, such as rect, ellipse, or a chorded arc, but rather a closed area bounded by lines which I've generated individually? I.e., I constructed the perimeter of the closed area. Thanks.
I'm a processing newbie. How would I create and fill a semicircle? I'm trying to create a circle, with one half filled with one color and the second half filled with another. I have no problem generating and filling predefined Processing shapes, such as rectangles and ellipses, but this has me stumped. Thanks.
I'm new to Processing. I have written a few elementary programs. In attempting to debug a simple graphics program, I want to output debugging data generated by the program to a file instead of to the console. It looks like createWriter() would allow me to do just that. However, when I code this into my program
and attempt to run it, I get "Cannot find anything named "output."". If I exclude this (i.e., if I remove line 17), the program runs fine. What do I need to do to get createWriter to work? Note: I am running the program in Java mode.
(note, the reason I'm debugging the program is because it works fine with segments=120, but not with segments=100. With 120, the circle is completed. With 100, it only gets to 300 degrees instead of the full 360, despite looping the full 100 times. Strange. Haven't figured out why yet.)