1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

photobot.Canvas.layer()

Syntax

canvas.layer(image, x=0, y=0, name="")

Description

Creates a new layer on the canvas from image, which is either the path of an image file (.jpg, .gif, .png) or a copied layer, or a PIL Image object. The image is positioned on the canvas horizontally at x pixels and vertically at y pixels measured from the top left corner. You can supply a name for the layer.

Returns the new layer index. Indices start at 1, this means the first layer is canvas.layers[1], the layer above canvas.layers[2] and so on. The bottom layer is reserved for the transparent background and must remain untouched.

Example

Adds the image file robot.jpg as the top layer of canvas.

photobot = ximport("photobot")
canvas = photobot.canvas(100, 100)
canvas.layer("images/robot.jpg")

Sets the opacity of the lowest layer in canvas.

canvas.layers[1].opacity(60)