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.Layer.copy()

Syntax

canvas.layers[i].copy()

Description

Returns a copy of layer i on the canvas. This is different from the Layer.duplicate() command, which duplicates the layer as a new layer on the canvas. The Layer.copy() command returns a copy of the layer object, that can be added to a different canvas with the Canvas.layer() command.

Example

This example shows how you can automate tasks by creating functions that return a processed layer copy. The brighten() function brightens any image you pass to it, and returns a layer copy. More complex functions could manipulate an image in this way without having to retype the same manipulations over and over.

photobot = ximport("photobot")
 
def brighten(image):
  canvas = photobot.canvas(100,100)
  canvas.layer(image)
  canvas.layers[1].brightness(1.2)
  return canvas.layers[1].copy()
 
canvas = photobot.canvas(100,100)
canvas.layer(brighten("robot.jpg"))
canvas.layer(brighten("penguin.jpg"))