I had been designing the visual subsystem for Co-related Space from my procedural language perspective. I learned to program before object-orientated programming languages were released into the wild.
So my deepest programming guilty secret is that I’ve never really learned to program OO (though I’ve used languages that had OO features).
I had even stubbed out many of the functions I imagined would be needed:
def reg_cell(x,y,r,g,b,shape,orient,mod1,str1,mod2,str2,mod3,str3,var): """add a cell to the frame; draw shapes; apply modifiers and variance; calculate collisions; create fusion and fission effects Args: x,y - center of cell (m) radius - radius of cell (m) r,g,b - power of beam for red, green, and blue shape - the shape to draw centered on x,y (circle, square, star) orient - the orientation of the shape in degrees off of 12:00 (degrees) mod1 - apply modifying function to the basic shape str1 - if applicable, how intense should mod1 apply (unit interval) mod2 - apply additional modifying function str2- strength of mod2 (unit interval) mod3- apply additional modifying function str3 - strength of mod3 (unit interval) var - degree of uniformity or randomness (unit interval) """ def reg_connector(x1,y1,x2,y2,r,g,b,mod1,str1,mod2,str2,mod3,str3,var): """add a connector to the frame; apply modifiers and variance; calculate pathfinding Args: x1,y1 - end point of connector (m) x2,y2 - end point of connector (m) r,g,b - power of beam for red, green, and blue mod1 - apply modifying function to the basic shape str1 - if applicable, how intense should mod1 apply (unit interval) mod2 - apply additional modifying function str2 - strength of mod2 (unit interval) mod3 - apply additional modifying function str3 - strength of mod3 (unit interval) var - degree of uniformity or randomness (unit interval) """
I had been stressing about how to represent the data structures of all the graphic objects the system would be creating. How would I draw these objects? And how would I apply the modifiers to entire lines?
I asked an engineer acquaintance some of these questions. He didn’t know the answer, but in typical engineering fashion, he answered another question that he did know. I asked a few mathematicians with similar results. Who knows these things?
I put some of my questions out on one of my social networking sites, and someone responded with a easy barrage of helpful advice and code. Who was that? Oh! I’d totally forgotten that one of my good friends is the tool guy for a major animation studio. His job, as he described it when I first met him, was to make complicated tools with simple interfaces for artists. He was the perfect person to answer these questions! This is a kind of fable about the treasures we can’t see that are right in front of us.
At the recommendation of this programmer friend, a lot of my data structures could be better redesigned using the OO capabilities of Python.
We spent four hours (which felt like an hour max) over beers, burritos, and a whiteboard designing some of the basic graphic objects for Co-related Space.
We designed the basic graphic object, with subclasses circles and lines.
Each line segment — whether part of a circle or a line — is actually cubic splines consisting of three points (two end points and a control point). The adjoining segments share points which are tracked with an index.
Then we worked on the mods.
I’m not sure what we were doing here, actually. This was after three hours and three beers.
I haven’t yet taken all of our whiteboard brainstorming and turned it into code, but that’s next.