Skip to content
Shaw edited this page Nov 12, 2015 · 5 revisions

Create a new Image element from a URL or Node (<img> or <canvas> usually) to be drawn on a Canvallax Instance.

Special Properties

In addition to the standard element properties, Canvallax.Image elements also utilize these properties, shown with the default properties:

  Canvallax.Image({
    
    src: null,
    // (String)
    // URL of the image to be rendered. Not necessary if an image node is provided
    
    image: null,
    // (Node)
    // Image node to be drawn on the canvas. If not provided, a new Image node will be created.
    
    width: null,
    // (Number)
    // Width to render the image. Will be set to the `src` image's width if not provided.
    
    height: null
    // (Number)
    // Height to render the image. Will be set to the `src` image's height if not provided.
    
  });

The default element properties of fill, stroke and lineWidth do not have any effect on Canvallax.Image elements.

Canvallax.Image elements can also be created using a string or a node as the only parameter:

  Canvallax.Image(document.getElementById('#my-image');
  Canvallax.Image('image.png');
Clone this wiki locally