The create canvas method is something that I made for my collection of canvas example posts, for that collection of posts like this collection I was not using any kind of framework and writing all the code from the ground up sort of speak. However I did reuse code from example to example, just as I do with this example, and one thing I wanted to work out is a standard way to create a canvas element, and set up some values for such an element. So then this create canvas method is such a method, and will return an object with a reference to the canvas element, as well as the 2d drawing content of the canvas element.
I then also have a wrapNumber method based off of what is used in the game frameWork known as phaser, along with distance and bounding box collection detection methods. I also have a chunk method that works in more or less the same way as that of the lodash chunk method as a basic tool for spiting an array into arrays of arrays. After that I have a whole bunch of methods that are based off of the source code from angles.js that work well for various tasks that have to do with angles.
The star module that I am suing for this example is based off of what I worked out for my older canvas example project and drawing stars. It is more or less the same source code, but of course I made some additions to it when it comes to creating an instance of this unsteady star object that I want to use as the main feature of the over all digital art example.
The unsteady star object is just like the same object that is returned by the create1 method of the star module from before. I went with the cerate1 method that works by creating just one line to make a star by bounding between an outer ind inner radius, rather than the other method that words by creating one or two lines depending if the number of points is even or not. So then what is returned by the main unsteady star method is also an Array, but with some named keys attached to the array. As you might guess these additional keys and corresponding values have to do with updating the main collection of points for the star. Speaking of updating things I also of course have an update method for this unsteady star object.
The object pool module was copied over from the other digital art example that I started this out from. It started out with what what I put together with in my canvas example on object pools. Sense then I keep making little changes to it here and there as needed, and over time I slowly but surly have a more solid module for this sort of thing.
In revision 0 of this example I started out with just a simply move mode that just moves a current display object in the units pool by the current heading and pps values of the object. As of revision 4 of this example there is a rebirth mode as well as two methods that have to do with movement. One movement mode is still a fairly simple movement mode that just goes by whatever the current settings are, and the other move2 mode will adjust the heading and speed while moving. The rebirth mode as the name suggests will cause the unit to undergo a kind of transformation from a current set of settings to a new set of settings, nit just with heading and speed but also the number of points in the star, colors, size, and so forth.
I then have a draw module that contains all the methods that I will be using to draw the current state of the game object to a canvas element.
So then I am glad that I followed threw with this project and have completed it by working out the core of the idea first, and also completed just the two features that I hand planed out for this. Of course I could just keep going with this project even further adding yet even more features that have come to mind for the project in terms of other movement modes, and well as whole other kinds of modes that have to do with completely different behavior all together. There is more that could be done with how to go about switching between modes, and also more advanced features for the background, colors, and so forth. However I did only want to spend at most a few days on this and then move on to the next project, which is what I will be doing.
So then the current plans with this at the time of this writing at least is to just do a little clean up with the code in order to help make the over all project a little easier to follow. I fixed all the bugs that I know of at this point as of revision 4 of this project, but I am sure there might be at least one or two more maybe. So then for the most part I intended to just maintain what the project all ready is rather than add more to it, unless of course something happens that might change that for me.