photobot.Layer.pixels[]

Syntax

canvas.layers[i].pixels[j]

Description

Returns pixel j in layer i. The total number of pixels in the array is equal to the layer's width * the layer's height. Each pixel is a 4-tuple containing (r,g,b,a) channel values.

Once the array has been updated, you need to call the Layer.pixels.update() command for the changes to commit.

Example

Add a reddish glow to the image by increasing all red pixels:

photobot = ximport("photobot")
canvas = photobot.canvas(100,100)
canvas.layer("robot.jpg")
pixels = canvas.layers[1].pixels
for i in range(len(pixels)):
  r, g, b, a = pixels[i]
  r += 20
  pixels[i] = r, g, b, a
pixels.update()