MC10
MC10

Reputation: 1

How to select part of an image, then paste the selected part of the image in a checkerboard pattern into another image using JES?

I am using Jython, or JES, and I want to repeatedly copy, in a checkerboard pattern, part of one image into another image. I am wondering how that might be done?

So far I have this:

def checkerboard(pic):
  p = makeEmptyPicture(500,500)
  targetX = 100
  for sourceX in range(81,123):
    targetY = 100
    for sourceY in range(99,126):
      color = getColor(getPixel(pic,sourceX,sourceY))
      setColor(getPixel(p,targetX,targetY),color)
      targetY = targetY + 1
    targetX = targetX + 1
  show(p)

Pic is the user selected image, and picX and picY are the ranges of the picture. The issue is that this just pastes part of an image once into the empty picture (p). I want the part of the image to be pasted repeatedly into the empty picture in a certain area of the empty picture.

Upvotes: 0

Views: 93

Answers (0)

Related Questions