Ary*_*wat -1 python linear-gradients turtle-graphics python-turtle
我目前正在尝试复制此图像: https://i.stack.imgur.com/fymWE.jpg 我正在尝试在背景中制作该渐变,但我不知道如何做到这一点,并且基本上没有任何内容互联网。编辑:如果有帮助的话,我有两端的 RGB 颜色。顶部为 rgb(154,0,254),底部为 rgb(221,122,80)。
粗略但相当快速有效:
from turtle import Screen, Turtle
COLOR = (0.60156, 0, 0.99218) # (154, 0, 254)
TARGET = (0.86328, 0.47656, 0.31250) # (221, 122, 80)
screen = Screen()
screen.tracer(False)
WIDTH, HEIGHT = screen.window_width(), screen.window_height()
deltas = [(hue - COLOR[index]) / HEIGHT for index, hue in enumerate(TARGET)]
turtle = Turtle()
turtle.color(COLOR)
turtle.penup()
turtle.goto(-WIDTH/2, HEIGHT/2)
turtle.pendown()
direction = 1
for distance, y in enumerate(range(HEIGHT//2, -HEIGHT//2, -1)):
turtle.forward(WIDTH * direction)
turtle.color([COLOR[i] + delta * distance for i, delta in enumerate(deltas)])
turtle.sety(y)
direction *= -1
screen.tracer(True)
screen.exitonclick()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8675 次 |
最近记录: |