designer-edu / designer

MIT License
5 stars 1 forks source link

Pixel manipulation functions #30

Open acbart opened 2 years ago

acbart commented 2 years ago

It's entirely possible to do pixel manipulation and retrieval with pygame surfaces. We need an easy-to-use api for this. Something vaguely like this:

frog = emoji('frog face')
# Get the pixels as a pseudo 2d array
pixels = get_pixels(frog)
# Modify
pixels[0][3] = 'red'
# Check it out
for row in pixels:
    for pixel in row:
        print(pixel)
# And back
modded_frog = image_from_pixels(pixels)

There's a lot of questions here about the best interface, but my thought is that you should be able to assign either strings or color-tuples to specific indices, replace entire rows with a list of the same, generally treat them like a 2-d list of tuples. Then there should also be a way to turn one of those back into an image.

acbart commented 2 years ago

Ultimately, we need to make sure we support the same set of functionality that you can do with Media Comp: http://personal.denison.edu/~bressoud/cs110-f12/Supplements/JESHelp/7_Picture_Functions.html