Class: Canvas

Canvas(model, property, height, width, scale)

Canvas is a wrapper-class for a HTML-canvas element. It is linked to a @Gridmodel object, and stores what from that @Gridmodel should be displayed (width, height, property, scale, etc.)

Constructor

new Canvas(model, property, height, width, scale)

The constructor function for a @Canvas object.
Parameters:
Name Type Description
model model The model ( @Gridmodel or @Flockmodel ) to which this canvas belongs
property string the property that should be shown on the canvas
height int height of the canvas (in rows)
width int width of the canvas (in cols)
scale scale of the canvas (width/height of each gridpoint in pixels)
Source:

Methods

displayflock()

Draw the state of the flockmodel onto the HTML element
Source:

displaygrid()

Draw the state of the model (for a specific property) onto the HTML element
Source:

displaygrid_dots()

Draw the state of the model (for a specific property) onto the HTML element
Source:

drawBoid()

This function is empty by default, and is overriden based on parameters chose by the model. Override options are all below this option. Options are: Point: a circle Rect: a square Arrow: an arrow that rotates in the direction the boid is moving Bird: an arrow, but very wide so it looks like a bird Line: a line that has the direction AND length of the velocity vector Ant: three dots form an ant body with two lines forming antanae Png: an image. PNG is sourced from boid.png
Source: