Images

drawBot.image(path, (x, y), alpha=1)

Add an image from a path with an offset and an alpha value. This should accept most common file types like pdf, jpg, png, tiff and gif.

Optionally an alpha can be provided, which is a value between 0 and 1.

# the path can be a path to a file or a url
image("http://f.cl.ly/items/1T3x1y372J371p0v1F2Z/drawBot.jpg", (100, 100), alpha=.3)
drawBot.imageSize(path)

Return the width and height of an image.

print imageSize("http://f.cl.ly/items/1T3x1y372J371p0v1F2Z/drawBot.jpg")
drawBot.imagePixelColor(path, (x, y))

Return the color r, g, b, a of an image at a specified x, y possition.

# path to the image
path = u"http://f.cl.ly/items/1T3x1y372J371p0v1F2Z/drawBot.jpg"

# get the size of the image
w, h = imageSize(path)

# setup a variable for the font size as for the steps
s = 15

# shift it up a bit
translate(100, 100)

# set a font with a size
font("Helvetica-Bold")
fontSize(s)

# loop over the width of the image
for x in range(0, w, s):
    # loop of the height of the image
    for y in range(0, h, s):
        # get the color
        color = imagePixelColor(path, (x, y))
        if color:
            r, g, b, a = color
            # set the color
            fill(r, g, b, a)
            # draw some text
            text("W", (x, y))