Question

I am trying to interweave two pictures.

Picture 1 Picture 1 Picture 2 Picture 2 To This REsult

def interWeave(pic, picture):
  w=getWidth(pic)
  h=getHeight(pic)
  newPic=makeEmptyPicture(w,h)
  for x in range (0,w):
    for y in range (0,h):
      p=getPixel(pic,x,y)
      p2=getPixel(picture,x,y)
      newPxl=getPixel(newPic,x,y)

      if (x>=0 and x<20) or (x>=40 and x<60)or (x>=80 and x<=100):
        color = getColor(p)

      else:
        color=getColor(p2)
        setColor(newPxl, color) 
  return (newPic)

But I get this:

newpic

Anyone know what I'm doing wrong?

Was it helpful?

Solution

if (x>=0 and x<20) or (x>=40 and x<60)or (x>=80 and x<=100):
        color = getColor(p)

      else:
        color=getColor(p2)
        setColor(newPxl, color)

If your indentatin is right, you only setColor in the else block. So the range from 0~20, 40~60, 80~100 will be blank.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top