本文整理匯總了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"