📜  随机十六进制颜色条生成器,python 龟 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:56.675000             🧑  作者: Mango

代码示例1
# Random Hex Colors bar generator, python turtle
from turtle import *
import random
from time import sleep

hideturtle()

n = 0
x = -200
y = 200

while True:
      speed(0)
      pensize(20)
      r = format(random.randint(16, 255), "x")
      g = format(random.randint(16, 255), "x")
      b = format(random.randint(16, 255), "x")
      
      ccode = "#"+r+g+b
      print(ccode)
      
      color(ccode)
      up()
      goto(x, y)
      down()
      
      fd(200)
      
      sleep(1)
      if len(ccode) < 7: continue
      y -= 20
      n += 1
      if n == 20: break
      

Screen().exitonclick()