Uploaded by Elisseth Amaya

sorceress zoom

advertisement
import sys
import stddraw
from picture import Picture
file_name = sys.argv[1]
width = int(sys.argv[2])
height = int(sys.argv[3])
file = Picture(file_name)
img = Picture(width, height)
for colT in range(width):
for rowT in range(height):
colS = colT * file.width() // width
rowS = rowT * file.height() // height
img.set(colT, rowT, file.get(colS, rowS))
stddraw.setCanvasSize(width, height)
stddraw.picture(img)
stddraw.show()
def main(file_name, scale_factor, x, y):
stddraw(stddraw.setXscale(x), stddraw.setYscale(y))
return scale(file_name, scale_factor)
def scale(image, scale_factor):
scale_Width = (width * scale_factor)
scale_Height = (height * scale_factor)
return stddraw.setCanvasSize(scale_Width, scale_Height)
def zoom(file_name, scale_factor, x, y):
scale(file_name, scale_factor)
image_extract(x, y, width, height) def image_extract(x, y, width, height):
x -= 1
y -= 1
return (x, y, width, height)
Download