1

さて、割り当てのためにcrop()、写真をトリミングする関数を作成する必要がありますtest_crop()。これがコードです。

def crop(pict, startX, startY, endX, endY):
 width = endX - startX + 1
 height = endY - startY + 1
 canvas = makeEmptyPicture(width, height)
 targetX = 100
 for sourceX in range(45,200):
  targetY = 100
  for sourceY in range(25,200):
    color = getColor(getPixel(pict, sourceX, sourceY))
    setColor(getPixel(canvas, targetX, targetY), color)
    targetY = targetY + 1
  targetX = targetX + 1
show(pict)
show(canvas)
return canvas

def test_crop():
 setMediaPath() 
 pict = makePicture("redMotorcycle.jpg")
 croppedPict = crop(pict, 100, 100, 700, getHeight(pict)/2)
 show(pict)
 show(croppedPict)

このコードでエラーが発生します。

setColor(getPixel(canvas, targetX, targetY), color)

それは言う"Inappropriate argument (of correct type. An error occured attempting to pass an argument to a function."

誰かがそれの何が悪いのか教えてもらえますか? 教科書と同じコードです。

4

1 に答える 1