monet.canvas

The canvas namespace provides functions which can be used for
rendering graphs, game graphics, art, or othe visual images
on the fly.

See http://www.w3.org/TR/html5/scripting-1.html#the-canvas-element and
http://www.w3.org/TR/2dcontext/

add-entity

(add-entity mc k ent)

alpha

(alpha ctx a)
Global Alpha value that is applied to shapes and images before they are
composited onto the canvas. Default 1.0 (opaque).

arc

(arc ctx {:keys [x y r start-angle end-angle counter-clockwise?]})
Draws an arc at position (x, y) with radius r, beginning at start-angle,
finishing at end-angle, in the direction specified.

begin-path

(begin-path ctx)
Starts a new path by resetting the list of sub-paths.
Call this method when you want to create a new path.

bezier-curve-to

(bezier-curve-to ctx cp1x cp1y cp2x cp2y x y)(bezier-curve-to ctx {:keys [cp1x cp1y cp2x cp2y x y]})

circle

(circle ctx {:keys [x y r]})
Draws a circle at position (x, y) with radius r

clear!

(clear! mc)

clear-rect

(clear-rect ctx {:keys [x y w h]})
Sets all pixels in the rectangle defined by starting point (x, y)
and size (w, h) to transparent black.

clip

(clip ctx)
Further constrains the clipping region to the current path.

close-path

(close-path ctx)
Tries to draw a straight line from the current point to the start.
If the shape has already been closed or has only one point, this
function does nothing.

composition-operation

(composition-operation ctx operation)
With Global Alpha applied this sets how shapes and images are drawn
onto the existing bitmap. Possible values (as string or keyword):
source-atop, source-in, source-out, source-over (default),
destination-atop, destination-in, destination-out, destination-over,
lighter, darker, copy, xor

draw-image

(draw-image ctx img x y)(draw-image ctx img {:keys [x y w h sx sy sw sh dx dy dw dh], :as params})
Draws the image onto the canvas at the given position.
If a map of params is given, the number of entries is used to
determine the underlying call to make.

draw-loop

(draw-loop {:keys [canvas updating? ctx active entities last-frame-time], :as mc})

ellipse

(ellipse ctx {:keys [x y rw rh]})
Draws an ellipse at position (x, y) with radius (rw, rh)

entity

(entity v update draw)

fill

(fill ctx)
Fills the subpaths with the current fill style.

fill-rect

(fill-rect ctx {:keys [x y w h]})
Draws a filled rectangle at (x, y) position whose size is determined
by width w and height h.

fill-style

(fill-style ctx color)
Color or style to use inside shapes. Default #000 (black).

font-style

(font-style ctx font)
Sets the font. Default value 10px sans-serif.

get-context

(get-context canvas type)

get-entity

(get-entity mc k)

get-pixel

(get-pixel ctx x y)
Gets the pixel value as a hash map of RGBA values

init

(init canvas & [context-type])

line-to

(line-to ctx x y)
Connects the last point in the subpath to the x, y coordinates with a
straight line.

monet-canvas

(monet-canvas elem context-type)

move-to

(move-to ctx x y)
Moves the starting point of a new subpath to the (x, y) coordinates.

quadratic-curve-to

(quadratic-curve-to ctx cpx cpy x y)(quadratic-curve-to ctx {:keys [cpx cpy x y]})

rect

(rect ctx {:keys [x y w h]})
Path for a rectangle at position (x, y) with a size (w, h).

remove-entity

(remove-entity mc k)

restart

(restart mc)

restore

(restore ctx)
Restores the drawing style state to the last element on the 'state stack'
saved by save.

rotate

(rotate ctx angle)
Rotate the context 

rounded-rect

(rounded-rect ctx {:keys [x y w h r]})

save

(save ctx)
Saves the current drawing style state using a stack so you can revert
any change you make to it using restore.

scale

(scale ctx x y)
Scales the context by a floating-point factor in each direction

start-updating

(start-updating mc)

stop

(stop mc)

stop-updating

(stop-updating mc)

stroke

(stroke ctx)
Strokes the subpaths with the current stroke style.

stroke-cap

(stroke-cap ctx cap)
Sets the line cap. Possible values (as string or keyword):
butt (default), round, square

stroke-join

(stroke-join ctx join)
Can be set, to change the line join style. Possible values (as string
or keyword): bevel, round, and miter. Other values are ignored.

stroke-rect

(stroke-rect ctx {:keys [x y w h]})
Paints a rectangle which has a starting point at (x, y) and has a
w width and an h height onto the canvas, using the current stroke
style.

stroke-style

(stroke-style ctx color)
Color or style to use for the lines around shapes. Default #000 (black).

stroke-width

(stroke-width ctx w)
Sets the line width. Default 1.0

text

(text ctx {:keys [text x y]})
Paints the given text at a starting point at (x, y), using the
current fill style.

text-align

(text-align ctx alignment)
Sets the text alignment attribute. Possible values (specified
as a string or keyword): start (default), end, left, right or
center.

text-baseline

(text-baseline ctx alignment)
Sets the text baseline attribute. Possible values (specified
as a string or keyword): top, hanging, middle, alphabetic (default),
ideographic, bottom

transform

(transform ctx m11 m12 m21 m22 dx dy)(transform ctx {:keys [m11 m12 m21 m22 dx dy]})
Multiplies a custom transformation matrix to the existing
HTML5 canvas transformation according to the follow convention:

[ x']   [ m11 m21 dx ] [ x ]
[ y'] = [ m12 m22 dy ] [ y ]
[ 1 ]   [ 0   0   1  ] [ 1 ]

translate

(translate ctx x y)
Moves the origin point of the context to (x, y).

update-entity

(update-entity mc k func & extra)