本文整理汇总了Python中turtle.RawTurtle方法的典型用法代码示例。如果您正苦于以下问题:Python turtle.RawTurtle方法的具体用法?Python turtle.RawTurtle怎么用?Python turtle.RawTurtle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle
的用法示例。
在下文中一共展示了turtle.RawTurtle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw
# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import RawTurtle [as 别名]
def draw(lines):
from tkinter import Tk, LEFT
from turtle import Canvas, RawTurtle, TurtleScreen
# set up the environment
root = Tk()
canvas = Canvas(root, width=800, height=800)
canvas.pack()
s = TurtleScreen(canvas)
t = RawTurtle(canvas)
t.speed(0)
t.width(1)
for line in lines:
x, y = line[0]
t.up()
t.goto(x*800/1024-400,-(y*800/1024-400))
for point in line:
t.down()
t.goto(point[0]*800/1024-400,-(point[1]*800/1024-400))
s.mainloop()
# -------------- conversion control --------------
示例2: main
# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import RawTurtle [as 别名]
def main():
root = TK.Tk()
cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
cv1.pack()
cv2.pack()
s1 = TurtleScreen(cv1)
s1.bgcolor(0.85, 0.85, 1)
s2 = TurtleScreen(cv2)
s2.bgcolor(1, 0.85, 0.85)
p = RawTurtle(s1)
q = RawTurtle(s2)
p.color("red", (1, 0.85, 0.85))
p.width(3)
q.color("blue", (0.85, 0.85, 1))
q.width(3)
for t in p,q:
t.shape("turtle")
t.lt(36)
q.lt(180)
for t in p, q:
t.begin_fill()
for i in range(5):
for t in p, q:
t.fd(50)
t.lt(72)
for t in p,q:
t.end_fill()
t.lt(54)
t.pu()
t.bk(50)
return "EVENTLOOP"