我需要制作三个条纹,第一个需要是形状高度的 40% 和 256 像素宽,红色分量从 0-255 逐渐增加并水平遍历图像
第二个是形状高度的 20%,宽度相同(高度 300)它是纯绿色
第三是形状高度的 40%,蓝色将从 255-0 减少
我在第二个 for 循环中不断收到错误 (rheight,rheight) 请帮忙!
def drawLines():
height = int(input("Enter Height: "))
width = 256
picture = makeEmptyPicture(width,height)
rheight = height*0.4
redValue = 0
for y in range(0,height):
for x in range(0,width):
pixel = getPixel(picture, x, y)
color = makeColor(redValue,0,0)
setColor(pixel, color)
redValue = redValue + 50
explore(picture)
for y in range(rheight,rheight):
for x in range(0, width):
pixel = getPixel(picture, x, y)
color = makeColor(0, 0, 0) # Change the current pixel to black
setColor(pixel, color)
explore(picture)