def tscheme_pixel(x, y, c):
"""Draw a filled box of pixels (default 1 pixel) at (x, y) in color c."""
check_type(c, scheme_stringp, 0, "pixel")
color = eval(c)
canvas = turtle.getcanvas()
w, h = canvas.winfo_width(), canvas.winfo_height()
if not hasattr(tscheme_pixel, 'image'):
_tscheme_prep()
tscheme_pixel.image = tkinter.PhotoImage(width=w, height=h)
canvas.create_image((0, 0), image=tscheme_pixel.image, state="normal")
size = tscheme_pixel.size
for dx in range(size):
for dy in range(size):
screenx, screeny = x * size + dx, h-(y * size + dy)
if 0 < screenx < w and 0 < screeny < h:
tscheme_pixel.image.put(color, (screenx, screeny))
return okay
评论列表
文章目录