下面的颜色表中的颜色更加鲜艳呢。
"""颜色表产生器""" import colorsys from random import * def randomcolor(): """设定随机颜色,颜色没那么鲜艳。""" r = randint(0,255) g = randint(0,255) b = randint(0,255) return r,g,b def makecolors(n=128): """产生颜色表,这种颜色表中的颜色更鲜艳""" cs = [] pass return cs # 以下是测试代码段 from turtle import * screen = Screen() screen.delay(0) screen.colormode(255) screen.bgcolor('black') screen.title('颜色表产生器') t = Turtle(shape='circle') t.penup() width = screen.window_width() height = screen.window_height() colorlist = makecolors() for _ in range(100): x = randint(-width//2,width//2) y = randint(-height//2,height//2) t.goto(x,y) t.dot(20,choice(colorlist)) #t.dot(20,randomcolor())
如需查看完整源代码,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)