1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Mirroring with Python

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024 às 23:12.

  1. Stack

    Stack Membro Participativo

    #Test code below

    myPic = makePicture( "nameOfYourFile.jpg" )
    mirrorVertical(myPic)
    mirrorHorizontal(myPic)
    writePictureTo( myPic, "mirrorOutput.jpg" )



    Now alter one or both of the mirroring functions you were given so that the bottom right quadrant of the image is repeated 4 times when you mirror the picture both horizontally and vertically. As always, repeat the following steps until your program works as it should: make a modification to the code, press play and remove any errors; when it runs without errors look at the output picture, and if not what you wanted, make another modification. (for an image that is 640 x 480 px (4:3)


    def mirrorBotTop(source):
    mirrorPoint = getHeight(source) / 2
    height =getHeight(source)
    for x in range (0,getWidth(source)):
    for y in range (0,mirrorPoint):
    bottomPixel = getPixel(source,x,height - y - 1)
    topPixel = get pixel(source,x,y)
    color = getColor(topPixel)
    setColor(bottomPixel)




    myPic = makePicture( "redMotorcycle.jpg" )
    mirrorHorizontal(myPic)
    mirrorVertical(myPic)
    writePictureTo( myPic, "mirrorOutput.jpg" )

    Continue reading...

Compartilhe esta Página