Question
Python Question Write a function that selects flower1.jpg and flower2.jpg (you can either code in the path to the file or use pickAFile()), creates a
Python Question
Write a function that selects flower1.jpg and flower2.jpg (you can either code in the path to the file or use pickAFile()), creates a new picture (using makeEmptyPicture()) that's width is the sum of the widths of flower1 and flower2. Using for loops copy flower1 then flower2 into your new picture. Also us show() and repaint() to show your picture and watch it change as the for loops run.
so far for what i have for this problem i just have no idea how to get the second flower to be placed on to the canvas the first flower works fine, but i get and error with the second one. Ive tried doubling the range and the x2 but it dones't work
Error: #Error: getPixel(picture,x,y): x (= 101) is less than 0 or bigger than the width (= 99)
#problem4
def longFlower():
file1 = pickAFile()
pict1 = makePicture(file1)
file2 = pickAFile()
pict2 = makePicture(file2)
canvas = makeEmptyPicture(getWidth(pict1)+getWidth(pict2), getHeight(pict1))
x1 = 0
y1 = 0
x2 = getWidth(pict1)
y2 = 0
for y in range(y1, getHeight(pict1)):# pict1 & pict2 Width = 100, Height = 100, canvas width = 200, Height = 100
for x in range(x1, getWidth(pict1)):
pixel1 = getPixel(pict1,x,y)
color1 = getColor(pixel1)
pixel2 = getPixel(canvas,x,y)
setColor(pixel2,color1)
for y in range(y2, getHeight(pict2)):
for x in range(x2+1, x2*2):
pixel1 = getPixel(pict2,x,y) #Error: getPixel(picture,x,y): x (= 101) is less than 0 or bigger than the width (= 99)
color1 = getColor(pixel1)
pixel2 = getPixel(canvas,x,y)
setColor(pixel2,color1)
explore(canvas)
pastebin: https://pastebin.com/h5g4DNtC
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started