I played around wiith this a little bit tonight, and thought I’d post some ideas to see if someone else has been working with the canvas yet. Personally, I see real possibilities with this.
I started using global variables instead of passing parameters into the function/method, which kind of made sense since they are only global within the scope of this canvas anyway (right?). The pump geometry parameters are still in a list, but my next step will be to make the list a list of individual pumps, so each one could look different based on tags. Basically, I want all of my pump geometry to reside in one place, and python lists are very fast.
I also simplified the offset calculation immensely by using the java translate function. Basically, on each iteration of a new pump, the x,y orgin is shifted to a new location. I didn’t think I could do that on individual items in the canvas, but it works fine. I can see how this could be used for some pretty cool animation.
Also, I added sliders to set the number of columns and dynamic scaling. It gives a good idea of how smoothly the graphics will update. Right now, the scaling is determined when the first pump is drawn, but could be set for each individual pump as well.
There are also two check boxes. One will generate a random number of pumps each timer cycle, and overrides the pump slider. The other is my “Whack-A-Mole” check box, and randomly selects a single pump out of the current list of pumps to display. There is a method to this madness: If I can match the mouse coordinates to a specific pump, I can change the appearance of that pump on the next update and make it look like it has been affected. There’s no better way to do that than making a whack-a-mole game to see how accurate my mouse clicks are.
Anyone else playing around with this stuff? I sure would like some pointers.
Pumps.fwin (73.3 KB)