Python turtle.begin_fill() Examples
The following are 10
code examples of turtle.begin_fill().
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: main.py From python-examples with MIT License | 6 votes |
def s(n, l): if n == 0: # stop conditions # draw filled rectangle turtle.color('black') turtle.begin_fill() for _ in range (4): turtle.forward(l) turtle.left(90) turtle.end_fill() else: # recursion # around center point create 8 smalles rectangles. # create two rectangles on every side # so you have to repeat it four times for _ in range(4): # first rectangle s(n-1, l/3) turtle.forward(l/3) # second rectangle s(n-1, l/3) turtle.forward(l/3) # go to next corner turtle.forward(l/3) turtle.left(90) # update screen turtle.update() # --- main --- # stop updating screen (to make it faster)
Example #3
Source File: My_Pink_Flower_en.py From pythonCodes with MIT License | 5 votes |
def draw_leaf(turtle): turtle.fillcolor("greenyellow") turtle.begin_fill() base = turtle.pos() turtle.circle(100,75) turtle.goto(base) turtle.circle(-100,75) turtle.goto(base) turtle.end_fill()
Example #4
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 5 votes |
def head(): ''' 头 ''' t.color((255, 155, 192), "pink") t.pu() t.seth(90) t.fd(41) t.seth(0) t.fd(0) t.pd() t.begin_fill() t.seth(180) t.circle(300, -30) # 顺时针画一个半径为300,圆心角为30°的园 t.circle(100, -60) t.circle(80, -100) t.circle(150, -20) t.circle(60, -95) t.seth(161) t.circle(-300, 15) t.pu() t.goto(-100, 100) t.pd() t.seth(-30) a = 0.4 for i in range(60): if 0 <= i < 30 or 60 <= i < 90: a = a + 0.08 t.lt(3) # 向左转3度 t.fd(a) # 向前走a的步长 else: a = a - 0.08 t.lt(3) t.fd(a) t.end_fill()
Example #5
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()
Example #6
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 #7
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 #8
Source File: base.py From Learning-Python-by-building-games with MIT License | 5 votes |
def square(x, y, size, name): """Draw square at `(x, y)` with side length `size` and fill color `name`. The square is oriented so the bottom left corner is at (x, y). """ import turtle turtle.up() turtle.goto(x, y) turtle.down() turtle.color(name) turtle.begin_fill() for count in range(4): turtle.forward(size) turtle.left(90) turtle.end_fill()
Example #9
Source File: main.py From python-examples with MIT License | 5 votes |
def hexagone(point, longueur,c): l = longueur x, y = point turtle.up() turtle.goto(point) turtle.color(c[0]) #black turtle.down() turtle.begin_fill() turtle.goto(l * cos(4 / 3 * pi )+x, l * sin(4 / 3 * pi)+y) turtle.goto(l * cos(5 / 3 * pi)+x, l * sin(5 / 3 * pi)+y) turtle.goto(l * cos(0)+x, l * sin(0)+y) turtle.goto(point) turtle.end_fill() turtle.color(c[1]) #blue turtle.begin_fill() turtle.goto(l * cos(0)+x, l * sin(0)+y) turtle.goto(l * cos(pi / 3)+x, l * sin(pi / 3)+y) turtle.goto(l * cos(pi * 2 / 3)+x, l * sin(pi * 2 / 3)+y) turtle.goto(point) turtle.end_fill() turtle.color(c[2]) #red turtle.begin_fill() turtle.goto(l * cos(pi * 2 / 3)+x, l * sin(pi * 2 / 3)+y) turtle.goto(-l+x, 0+y) turtle.goto(l * cos(4 / 3 * pi)+x, l * sin(4 / 3 * pi)+y) turtle.goto(point) turtle.end_fill() turtle.up() return True
Example #10
Source File: xzpq.py From You-are-Pythonista with GNU General Public License v3.0 | 4 votes |
def norse(): ''' 鼻子 ''' t.pu() # 提笔 t.goto(-100, 100) # 画笔前往坐标(-100,100) t.pd() # 下笔 t.seth(-30) # 笔的角度为-30° t.begin_fill() # 外形填充的开始标志 a = 0.4 for i in range(120): if 0 <= i < 30 or 60 <= i < 90: a = a + 0.08 t.lt(3) # 向左转3度 t.fd(a) # 向前走a的步长 else: a = a - 0.08 t.lt(3) t.fd(a) t.end_fill() # 依据轮廓填充 t.pu() # 提笔 t.seth(90) # 笔的角度为90度 t.fd(25) # 向前移动25 t.seth(0) # 转换画笔的角度为0 t.fd(10) t.pd() t.pencolor(255, 155, 192) # 设置画笔颜色 t.seth(10) t.begin_fill() t.circle(5) # 画一个半径为5的圆 t.color(160, 82, 45) # 设置画笔和填充颜色 t.end_fill() t.pu() t.seth(0) t.fd(20) t.pd() t.pencolor(255, 155, 192) t.seth(10) t.begin_fill() t.circle(5) t.color(160, 82, 45) t.end_fill()