Skip to content

The Canvas constructor

Corrado Canepari edited this page Apr 15, 2017 · 1 revision

The Canvas object is the core of Mare.js. It's the object you do all your rendering on: without it, you could not do anything.

Let's take a look at the constructor. There are a few ways to create a canvas object:

let canvas = new Mare.Canvas()

This will create a canvas with width and height of 400 * 400 px.

let canvas = new Mare.Canvas(500)

This will create a canvas with width and height of 500 px since, if you only use one argument, Mare automatically assumes that you want width and height to be equal.

let canvas = new Mare.canvas(600, 550)

Finally, this will create a new canvas with width and height of 600 * 500 px.

What other properties does the canvas object have?

Well, it has a default background color (black or, as it is expressed inside the class, [0, 0, 0]), a default fill color (white, or [255, 255, 255]) and a default stroke color (black, or [0, 0, 0])

Clone this wiki locally