Pregunta

This is my code it flips the picture. I need to it flip 180 degrees and this code I have now flips it -180 degrees. I can not figure out how to change this. It will not let me post of pic of what I am talking about so hopefully y'all get what I am saying.

def flip(picture):
    width = getWidth(picture)
    height = getHeight(picture)
    for y in range(0, height/2):
      for x in range(0, width):
        p1 = getPixel(picture, x, y)
        p2 = getPixel(picture, x, height - y - 1,)
        color = getColor(p1)
        setColor(p1, getColor(p2))
        setColor(p2, color)
¿Fue útil?

Solución

Try this. I had the same problem, we dealt with the height, but not the width.

def flip(picture):
    width = getWidth(picture)
    height = getHeight(picture)
    for y in range(0, height/2):
      for x in range(0, width):
        **p1 = getPixel(picture, width - 1 - x, y)**
        p2 = getPixel(picture, x, height - 1 - y,)
        color = getColor(p1)
        setColor(p1, getColor(p2))
        setColor(p2, color)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top