Python turtle.fd() Examples
The following are 30
code examples of turtle.fd().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
turtle
, or try the search function
.
Example #1
Source File: turtle_dsl.py From lark with MIT License | 6 votes |
def run_instruction(t): if t.data == 'change_color': turtle.color(*t.children) # We just pass the color names as-is elif t.data == 'movement': name, number = t.children { 'f': turtle.fd, 'b': turtle.bk, 'l': turtle.lt, 'r': turtle.rt, }[name](int(number)) elif t.data == 'repeat': count, block = t.children for i in range(int(count)): run_instruction(block) elif t.data == 'fill': turtle.begin_fill() run_instruction(t.children[0]) turtle.end_fill() elif t.data == 'code_block': for cmd in t.children: run_instruction(cmd) else: raise SyntaxError('Unknown instruction: %s' % t.data)
Example #2
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 6 votes |
def body(): ''' 身体 ''' t.color("red", (255, 99, 71)) t.pu() t.seth(90) t.fd(-20) t.seth(0) t.fd(-78) t.pd() t.begin_fill() t.seth(-130) t.circle(100, 10) t.circle(300, 30) t.seth(0) t.fd(230) t.seth(90) t.circle(300, 30) t.circle(100, 3) t.color((255, 155, 192), (255, 100, 100)) t.seth(-135) t.circle(-80, 63) t.circle(-150, 24) t.end_fill()
Example #3
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 6 votes |
def tail(): ''' 尾巴 ''' t.pensize(4) t.color((255, 155, 192)) t.pu() t.seth(90) t.fd(70) t.seth(0) t.fd(95) t.pd() t.seth(0) t.circle(70, 20) t.circle(10, 330) t.circle(70, 30)
Example #4
Source File: main-1-draw_1-right.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #5
Source File: main-2-draw_1-left-right.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #6
Source File: main-1-draw_1-right.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #7
Source File: main-4-draw_2-right-right.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #8
Source File: main-4-draw_2-left-right.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #9
Source File: main-4-draw_2-left-right.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #10
Source File: main-2-draw_1-right-right.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #11
Source File: main-2-draw_1-right-right.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #12
Source File: main-1-draw_1-left.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #13
Source File: main-4-draw_2-left-left.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #14
Source File: main-4-draw_2-left-left.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #15
Source File: main-3-draw_2-left.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #16
Source File: main-3-draw_2-left.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #17
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def horizontal(dx): # 做到相对横坐标为dx的水平线 te.seth(0) te.pendown() te.fd(dx) te.penup()
Example #18
Source File: homura.py From turtle-vectorgraph with MIT License | 5 votes |
def vertical(dy): # 做到相对纵坐标为dy的垂直线 te.seth(-90) te.pendown() te.fd(dy) te.penup() te.seth(0)
Example #19
Source File: main-2-draw_1-left-right.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #20
Source File: main-2-draw_1-left-left.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #21
Source File: main-3-draw_2-right.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #22
Source File: main-3-draw_2-right.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #23
Source File: main-2-left-right-draw_1.py From python-examples with MIT License | 5 votes |
def draw_2(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_2(length, level-1) turtle.left(60) draw_2(length, level-1) turtle.right(180-60) draw_2(length, level-1) turtle.left(60) draw_2(length, level-1)
Example #24
Source File: main-2-left-right-draw_1.py From python-examples with MIT License | 5 votes |
def draw_1(length, level): if level < 1: turtle.fd(length) else: length = length/3 draw_1(length, level-1) turtle.left(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.right(90) draw_1(length, level-1) turtle.left(90) draw_1(length, level-1)
Example #25
Source File: bqb.py From You-are-Pythonista with GNU General Public License v3.0 | 5 votes |
def arc(sa, ea, x, y, r): # start angle,end angle,circle center,radius turtle.penup() turtle.goto(x, y) turtle.setheading(0) turtle.left(sa) turtle.fd(r) turtle.pendown() turtle.left(90) turtle.circle(r, (ea - sa)) return turtle.position()
Example #26
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 5 votes |
def foot(): ''' 脚 ''' t.pensize(10) t.color((240, 128, 128)) t.pu() t.seth(90) t.fd(-75) t.seth(0) t.fd(-180) t.pd() t.seth(-90) t.fd(40) t.seth(-180) t.color("black") t.pensize(15) t.fd(20) t.pensize(10) t.color((240, 128, 128)) t.pu() t.seth(90) t.fd(40) t.seth(0) t.fd(90) t.pd() t.seth(-90) t.fd(40) t.seth(-180) t.color("black") t.pensize(15) t.fd(20)
Example #27
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 5 votes |
def hand(): ''' 手 ''' t.color((255, 155, 192)) t.pu() t.seth(90) t.fd(-40) t.seth(0) t.fd(-27) t.pd() t.seth(-160) t.circle(300, 15) t.pu() t.seth(90) t.fd(15) t.seth(0) t.fd(0) t.pd() t.seth(-10) t.circle(-20, 90) t.pu() t.seth(90) t.fd(30) t.seth(0) t.fd(237) t.pd() t.seth(-20) t.circle(-300, 15) t.pu() t.seth(90) t.fd(20) t.seth(0) t.fd(0) t.pd() t.seth(-170) t.circle(20, 90)
Example #28
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 5 votes |
def blusher(): ''' 腮 ''' t.color((255, 155, 192)) t.pu() t.seth(90) t.fd(-95) t.seth(0) t.fd(65) t.pd() t.begin_fill() t.circle(30) t.end_fill()
Example #29
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 5 votes |
def eye(): ''' 眼睛 ''' t.color((255, 155, 192), "white") t.pu() t.seth(90) t.fd(-20) t.seth(0) t.fd(-95) t.pd() t.begin_fill() t.circle(15) t.end_fill() t.color("black") t.pu() t.seth(90) t.fd(12) t.seth(0) t.fd(-3) t.pd() t.begin_fill() t.circle(3) t.end_fill() t.color((255, 155, 192), "white") t.pu() t.seth(90) t.fd(-25) t.seth(0) t.fd(40) t.pd() t.begin_fill() t.circle(15) t.end_fill() t.color("black") t.pu() t.seth(90) t.fd(12) t.seth(0) t.fd(-3) t.pd() t.begin_fill() t.circle(3) t.end_fill()
Example #30
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 5 votes |
def ear(): ''' 耳朵 ''' t.color((255, 155, 192), "pink") t.pu() t.seth(90) t.fd(-7) t.seth(0) t.fd(70) t.pd() t.begin_fill() t.seth(100) t.circle(-50, 50) t.circle(-10, 120) t.circle(-50, 54) t.end_fill() t.pu() t.seth(90) t.fd(-12) t.seth(0) t.fd(30) t.pd() t.begin_fill() t.seth(100) t.circle(-50, 50) t.circle(-10, 120) t.circle(-50, 56) t.end_fill()