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.gradient()

Syntax

canvas.gradient(style, w=1.0, h=1.0, name="")

Description

Creates a grayscale gradient layer, that is usually used together with the Layer.mask() command. All the imaging commands work on gradients, so they can easily be flipped, rotated, scaled, inverted, made brighter or darker. The style can be either LINEAR, RADIAL and DIAMOND. The gradient w (width) and h (height) can be supplied as percentages or in pixels. They fill the canvas by default. You can supply a name for the gradient layer.

Example

Assigns a linear gradient to the alpha channel of robot.jpg, making the image go from transparent (left) to opaque (right).

photobot = ximport("photobot")
canvas = photobot.canvas(100,100)
canvas.layer("images/robot.jpg")
canvas.gradient(photobot.LINEAR)
canvas.layers[2].mask()