'dimY' and 'dimX' define the number of rows and columns in the grid. 'origin' is the upper-left-hand corner of the grid. The first block of code defines the parameters that control the structure of the grid and the speed of layer movement. StartY = Math.floor(random(dimY))*gap + origin ĮndX = Math.floor(random(dimX))*gap + origin ĮndY = Math.floor(random(dimY))*gap + origin Įnd += (deltaX + deltaY)/gridRate + 2*holdTime Įase(time,start,p1,)Įase(time,p2,p3,) StartX = Math.floor(random(dimX))*gap + origin
GridRate = 300 //speed (pixels per second) Gap = 20 // distance between cells (pixels) Origin = //upper left hand corner of grid Each time a layer reaches a grid intersection, we want it pause there for a pre-determined length of time. Furthermore, we want this motion to be directed along a grid.
Then we want to generate a smooth random motion that only occurs in the x or y direction. At the beginning, we want each layer to position itself randomly at a grid intersection (which means we can develop our expression for one layer and then duplicate the layer a bunch of times and have the duplicates randomly populate the grid). First we need to lay out the requirements for this little project. Now let's really jump into the deep end of the pool and look at a much more complex example.