# NodeBox

Create visual output with Python programming code
Home Download Reference Tutorial Library Gallery About

# 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()