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