我一直在修改此代码以充当屏幕保护程序。我一直遇到1像素显示的问题;我需要增大乌龟笔的大小,但是没有地方可以在启动失败时放它;我尝试了在顶部,中间和底部都无济于事。
from turtle import *
import random
from random import randint # from the random module import the function randint
#like turtle it is a module, read ahead for use
speed(9999999)
bgcolor('black')
x = 1
while x < 40099999999999999:
r = randint(0,255) #makes variables r,g,b whose value is an integer,
g = randint(0,255) # which is between 0 and 255. It is random, and
b = randint(0,255) # changes every time the loop runs
colormode(255) # this is something that is irrelevant at this point - unless you are using python 2.
pencolor(r,g,b) # changes the color of the pen to the rgb coordinates
# obtained by the variables r, g, b changing each time
fd(random.random() + random.randrange(99) * random.random())
rt(90)#V1.1 - removed the random for this module - no reason to have random for the same number - wastes cpu power.
x = x+1
谢谢; amdcrash。
答案 0 :(得分:0)
我猜你在问如何使线变粗。如果您提供要修改的原始代码以及版本,这将有所帮助。我相信这可以满足您的描述,并可以解决代码中的其他问题:
from turtle import *
from random import random, randrange
speed('fastest')
width(3) # "i need to put the turtle pen size up"
bgcolor('black')
colormode(255)
for x in range(1_000_000):
r = randrange(256) # makes variables r,g,b whose value is an integer,
g = randrange(256) # which is between 0 and 255. It is random, and
b = randrange(256) # changes every time the loop runs
pencolor(r, g, b) # changes the color of the pen to the rgb coordinates
forward(random() + randrange(99) * random())
right(90)