scheme_primitives.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:Scheme 作者: StephenK1998 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号