# NodeBox

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

# photobot.Layer.pixels.update()

## Syntax

    canvas.layers[i].pixels.update()

## Description

Updates the pixels array of layer i after it has been modified. To save time, changes to the Layer.pixels[] pixels array only take effect after calling this command.

## Example

Remove all white pixels from the given image, with a feather at the edges of white areas:

    photobot = ximport("photobot")
    canvas = photobot.canvas(200,200)
    canvas.layer("smurf.gif")

    w = canvas.layers[1].w
    feather = [-w-1, -w, -w+1, -1, 1, w-1, w, w+1]

    pixels = canvas.layers[1].pixels
    for i in range(len(pixels)):
        r, g, b, a = pixels[i]
        if r == g == b == 255:
            pixels[i] = r, g, b, 0
            for j in feather:
                r, g, b, a = pixels[i+j]
                pixels[i+j] = r, g, b, a/2

    pixels.update()