# warhol.py
from Processing import *

# Load image three times
warhol_r = loadImage("images/andy-warhol2.jpg")
warhol_g = loadImage("images/andy-warhol2.jpg")
warhol_b = loadImage("images/andy-warhol2.jpg")

# Load all pixels to allow color manipulation
warhol_r.loadPixels()
warhol_g.loadPixels()
warhol_b.loadPixels()

# Create window three times image width
w = warhol_r.width()
h = warhol_r.height()
window(3*w, h)

# Load pixels in image to allow pixel manipulation
for i in range(w):
    for j in range(h):
        c = warhol_r.getPixel(i, j)
        c = color( red(c), 0, 0 )
        warhol_r.setPixel(i, j, c)

        c = warhol_g.getPixel(i, j)
        c = color( 0, green(c), 0 )
        warhol_g.setPixel(i, j, c)

        c = warhol_b.getPixel(i, j)
        c = color( 0, 0, blue(c) )
        warhol_b.setPixel(i, j, c)

# Update pixels in images
warhol_r.updatePixels()
warhol_g.updatePixels()
warhol_b.updatePixels()

# Draw modified images
image(warhol_r, 0, 0)
image(warhol_g, w, 0)
image(warhol_b, 2*w, 0)
