Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, I was wondering if it was possible to write a function in python or jython that would allow me to mirror any picture across

Hello,

I was wondering if it was possible to write a function in python or jython that would allow me to mirror any picture across it's diagonal line for e.g. mirroring across the points (0,0) and (width,height). The image can be any size and can be rectanglar shape. I can do it if it is a square shape with this code but I cannot do a perfect mirror diagonally with rectangle pictures and it skips a section. Here is my code:

def mirror1(): picture=makePicture(pickAFile()) width=getWidth(picture) height=getHeight(picture) #needed this if statement so it mirrors from a square shape if height>getWidth(picture): height=getWidth(picture) for x in range(0,width): for y in range(0,height): oldPixel=getPixel(picture,x,y) newPixel=getPixel(picture,y,x) color=getColor(newPixel) setColor(oldPixel,color) show(picture)

As mentioned earlier it needs to be able to mirror any size image across its diagonal perfect and not be restricted to squares. Any help would be greatly appreciated. Thanks.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

Students also viewed these Databases questions