Drawing and moving shapes
I»ve been modifying the previous exercise in order to move the shapes that were created with the drawing tool.
I thought that moving each one of the shapes will be very difficult because each one of them had to know if it was selected or not, and actually it took me a lot of time to figure out how it could work.
The final solution consist on use a variable called selectedShape where the array»s index of the shape that we want to move is saved, so then we can move the shapes calling the array (something like arrayOfShapes[selectedShape]), and the call the function that will update the vertex points of the shape to the new locations (something like arrayOfShapes[selectedShape].updateVertex();).
Here is a video to see how it works:
Learning OpenFrameworks: Drawing and moving shapes from berio on Vimeo.
And this is the code:
I will use this tool in the future to create spaces with a video projector interacting maybe with a laser or a wii. But I will talk about it other day.
These days I»ve been also trying to install addons into a openframeworks project. That was the second time I tryed to do it, and finally I succed. If you have the same problem that I had, check this post on the openframeworks forum, it helped me a lot:
http://www.openframeworks.cc/forum/viewtopic.php?t=491&highlight=addons.
So I just created an addon where I put some functions that I usually use (actually I only put one function stolen from processing called ofDist(), that I later realized that was inside of another addon called ofxTodd, which has implemented several other processing similar functions like for instance constrain(), which is nice!). I called my tiny addon MyFunctions, and you will see it inside the code that I posted above.