炫彩波浪线动画

python sin cos line cool color炫彩波浪线动画

python sin cos line cool color炫彩波浪线动画

"""
   炫彩波浪线,这个程序并不复杂,它只是在画很多正弦曲线。
   运行这个程序后,会有动画效果,这是由于不断地用屏幕
   的update命令刷新的结果。
"""

import math
from turtle import *
from coloradd import *

def draw_wave(turtle,pos):
    """画一根波浪线"""
    c = (255,0,0)    
    turtle.penup()
    turtle.goto(pos)
    turtle.pendown()
    for angle in range(-width//2,width//2):
        turtle.color(c)
        x = math.radians(angle)      # 弧度值
        y = pos[1] + 30 * math.sin(x)# y坐标值
        turtle.goto(angle,y)         # 定位坐标   
        c = coloradd(c,0.01)         # 颜色增加
    screen.update()                  # 屏幕更新
    
width,height = 480,360
screen = Screen()
screen.colormode(255)
screen.setup(width,height)
screen.title("波浪炫彩图")

You must log in to read the rest of this article. Please log in or register as a user.