Class: Caman.Layer

Defined in: src/core/


The entire layering system for Caman resides in this file. Layers get their own canvasLayer objectwhich is created when newLayer() is called. For extensive information regarding the specifics of howthe layering system works, there is an in-depth blog post on this very topic. Instead of copying the entirety of that post, I'll simply point you towards the blog link.

However, the gist of the layering system is that, for each layer, it creates a new canvas element and then either copies the parent layer's data or applies a solid color to the new layer. After some (optional) effects are applied, the layer is blended back into the parent canvas layer using one of many different blending algorithms.

You can also load an image (local or remote, with a proxy) into a canvas layer, which is useful if you want to add textures to an image.

Instance Method Summary

Constructor Details

- (void) constructor(c)

Instance Method Details

- (void) newLayer(cb)

If you want to create nested layers

- (void) setBlendingMode(mode)

Sets the blending mode of this layer. The mode is the name of a blender function.

- (void) opacity(opacity)

Sets the opacity of this layer. This affects how much of this layer is applied to the parent layer at render time.

- (void) copyParent()

Copies the contents of the parent layer to this layer

- (void) fillColor()

Fills this layer with a single color

- (void) overlayImage(image)

Loads and overlays an image onto this layer

- (void) applyToParent()

Takes the contents of this layer and applies them to the parent layer at render time. This should never be called explicitly by the user.