Python turtle.pendown() Examples

The following are 21 code examples of turtle.pendown(). 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: main.py    From python-turtle-draw-svg with GNU General Public License v3.0 6 votes vote down vote up
def Bezier_3(x1, y1, x2, y2, x3, y3, x4, y4):  # 三阶贝塞尔函数
    x1 = -Width / 2 + x1
    y1 = Height / 2 - y1
    x2 = -Width / 2 + x2
    y2 = Height / 2 - y2
    x3 = -Width / 2 + x3
    y3 = Height / 2 - y3
    x4 = -Width / 2 + x4
    y4 = Height / 2 - y4  # 坐标变换
    te.goto(x1, y1)
    te.pendown()
    for t in range(0, WriteStep + 1):
        x = Bezier(Bezier(Bezier(x1, x2, t / WriteStep), Bezier(x2, x3, t / WriteStep), t / WriteStep),
                   Bezier(Bezier(x2, x3, t / WriteStep), Bezier(x3, x4, t / WriteStep), t / WriteStep), t / WriteStep)
        y = Bezier(Bezier(Bezier(y1, y2, t / WriteStep), Bezier(y2, y3, t / WriteStep), t / WriteStep),
                   Bezier(Bezier(y2, y3, t / WriteStep), Bezier(y3, y4, t / WriteStep), t / WriteStep), t / WriteStep)
        te.goto(x, y)
    te.penup() 
Example #2
Source File: homura.py    From turtle-vectorgraph with MIT License 6 votes vote down vote up
def Bezier_3(x1, y1, x2, y2, x3, y3, x4, y4):  # 三阶贝塞尔函数
    x1 = -Width / 2 + x1
    y1 = Height / 2 - y1
    x2 = -Width / 2 + x2
    y2 = Height / 2 - y2
    x3 = -Width / 2 + x3
    y3 = Height / 2 - y3
    x4 = -Width / 2 + x4
    y4 = Height / 2 - y4  # 坐标变换
    te.goto(x1, y1)
    te.pendown()
    for t in range(0, WriteStep + 1):
        x = Bezier(Bezier(Bezier(x1, x2, t / WriteStep), Bezier(x2, x3, t / WriteStep), t / WriteStep),
                   Bezier(Bezier(x2, x3, t / WriteStep), Bezier(x3, x4, t / WriteStep), t / WriteStep), t / WriteStep)
        y = Bezier(Bezier(Bezier(y1, y2, t / WriteStep), Bezier(y2, y3, t / WriteStep), t / WriteStep),
                   Bezier(Bezier(y2, y3, t / WriteStep), Bezier(y3, y4, t / WriteStep), t / WriteStep), t / WriteStep)
        te.goto(x, y)
    te.penup() 
Example #3
Source File: main-colors-asymmetrical.py    From python-examples with MIT License 6 votes vote down vote up
def item(lenght, level, color):
    if level <= 0:
        return
    
    for _ in range(5):    # 5
        turtle.color(colors[color])
        turtle.forward(lenght)
        
        item(lenght/4, level-1, color+1)
        
        turtle.penup() # there is no need to draw again the same line  (and it can use differnt color)
        turtle.backward(lenght)
        turtle.pendown()
        
        turtle.right(360/8) # 8
    
    turtle.right(360/8 * 3) # 3 = 8 - 5 
Example #4
Source File: bqb.py    From You-are-Pythonista with GNU General Public License v3.0 5 votes vote down vote up
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 #5
Source File: homura.py    From turtle-vectorgraph with MIT License 5 votes vote down vote up
def polyline(x1, y1, x2, y2, x3, y3):  # 做svg坐标下的折线
    te.penup()
    te.goto(-Width / 2 + x1, Height / 2 - y1)
    te.pendown()
    te.goto(-Width / 2 + x2, Height / 2 - y2)
    te.goto(-Width / 2 + x3, Height / 2 - y3)
    te.penup() 
Example #6
Source File: homura.py    From turtle-vectorgraph with MIT License 5 votes vote down vote up
def vertical(dy):  # 做到相对纵坐标为dy的垂直线
    te.seth(-90)
    te.pendown()
    te.fd(dy)
    te.penup()
    te.seth(0) 
Example #7
Source File: homura.py    From turtle-vectorgraph with MIT License 5 votes vote down vote up
def horizontal(dx):  # 做到相对横坐标为dx的水平线
    te.seth(0)
    te.pendown()
    te.fd(dx)
    te.penup() 
Example #8
Source File: homura.py    From turtle-vectorgraph with MIT License 5 votes vote down vote up
def Lineto(x, y):  # 连接当前点和svg坐标下(x,y)
    te.pendown()
    te.goto(-Width / 2 + x, Height / 2 - y)
    te.penup() 
Example #9
Source File: homura.py    From turtle-vectorgraph with MIT License 5 votes vote down vote up
def lineto(dx, dy):  # 连接当前点和相对坐标(dx,dy)的点
    te.pendown()
    te.goto(te.xcor() + dx, te.ycor() - dy)
    te.penup() 
Example #10
Source File: homura.py    From turtle-vectorgraph with MIT License 5 votes vote down vote up
def line(x1, y1, x2, y2):  # 连接svg坐标下两点
    te.penup()
    te.goto(-Width / 2 + x1, Height / 2 - y1)
    te.pendown()
    te.goto(-Width / 2 + x2, Height / 2 - y2)
    te.penup() 
Example #11
Source File: homura.py    From turtle-vectorgraph with MIT License 5 votes vote down vote up
def Bezier_2(x1, y1, x2, y2, x3, y3):  # 二阶贝塞尔函数
    te.goto(x1, y1)
    te.pendown()
    for t in range(0, WriteStep + 1):
        x = Bezier(Bezier(x1, x2, t / WriteStep),
                   Bezier(x2, x3, t / WriteStep), t / WriteStep)
        y = Bezier(Bezier(y1, y2, t / WriteStep),
                   Bezier(y2, y3, t / WriteStep), t / WriteStep)
        te.goto(x, y)
    te.penup() 
Example #12
Source File: main-colors.py    From python-examples with MIT License 5 votes vote down vote up
def item(lenght, level, color):
    if level <= 0:
        return
    
    for _ in range(8):
        turtle.color(colors[color])
        turtle.forward(lenght)
        
        item(lenght/4, level-1, color+1)
        
        turtle.penup() # there is no need to draw again the same line (and it can use differnt color)
        turtle.backward(lenght)
        turtle.pendown()
        
        turtle.right(360/8) 
Example #13
Source File: Palestine_en.py    From pythonCodes with MIT License 5 votes vote down vote up
def writetext(text,color,x,y):
   for i in range(1,10):
      turtle.penup()
      turtle.setx(x)
      turtle.sety(y)
      turtle.pendown
   
   turtle.pencolor(color)
   turtle.write(text,move=True, font=("Arial",16,"normal")) 
Example #14
Source File: circles-picture.py    From advancedpython3 with GNU General Public License v3.0 5 votes vote down vote up
def draw_circle(x, y, radius, red=50, green=255, blue=10, width=7):
    """ Draw a circle at a specific x, y location.
    Then draw four smaller circles recursively"""
    colour = (red, green, blue)

    # Recursively drawn smaller circles
    if radius > 50:
        # Calculate colours and line width for smaller circles
        if red < 216:
            red = red + 33
            green = green - 42
            blue = blue + 10
            width -= 1
        else:
            red = 0
            green = 255
        # Calculate the radius for the smaller circles
        new_radius = int(radius / 1.3)
        # Drawn four circles
        draw_circle(int(x + new_radius), y, new_radius, red, green, blue, width)
        draw_circle(x - new_radius, y, new_radius, red, green, blue, width)
        draw_circle(x, int(y + new_radius), new_radius, red, green, blue, width)
        draw_circle(x, int(y - new_radius), new_radius, red, green, blue, width)

    # Draw the original circle
    turtle.goto(x, y)
    turtle.color(colour)
    turtle.width(width)
    turtle.pendown()
    turtle.circle(radius)
    turtle.penup()


# Run the program 
Example #15
Source File: snowflake.py    From advancedpython3 with GNU General Public License v3.0 5 votes vote down vote up
def draw_snowflake(size):
    """ Draw a picture of a snowflake """
    turtle.penup()
    turtle.forward(10 * size)
    turtle.left(45)
    turtle.pendown()
    turtle.color(generate_random_colour())

    # draw branch 8 times to make a snowflake
    for _ in range(8):
        draw_branch(size)
        turtle.forward(size)
        turtle.left(45)

    turtle.penup() 
Example #16
Source File: clock.py    From Tools with MIT License 5 votes vote down vote up
def move(distance):
	turtle.penup()
	turtle.forward(distance)
	turtle.pendown() 
Example #17
Source File: main.py    From python-turtle-draw-svg with GNU General Public License v3.0 5 votes vote down vote up
def Lineto(x, y):  # 连接当前点和svg坐标下(x,y)
    te.pendown()
    te.goto(-Width / 2 + x, Height / 2 - y)
    te.penup() 
Example #18
Source File: main.py    From python-turtle-draw-svg with GNU General Public License v3.0 5 votes vote down vote up
def line(x1, y1, x2, y2):  # 连接svg坐标下两点
    te.penup()
    te.goto(-Width / 2 + x1, Height / 2 - y1)
    te.pendown()
    te.goto(-Width / 2 + x2, Height / 2 - y2)
    te.penup() 
Example #19
Source File: main.py    From python-turtle-draw-svg with GNU General Public License v3.0 5 votes vote down vote up
def Moveto_r(dx, dy):
    te.penup()
    te.goto(te.xcor() + dx, te.ycor() - dy)
    te.pendown() 
Example #20
Source File: main.py    From python-turtle-draw-svg with GNU General Public License v3.0 5 votes vote down vote up
def Moveto(x, y):  # 移动到svg坐标下(x,y)
    te.penup()
    te.goto(-Width / 2 + x, Height / 2 - y)
    te.pendown() 
Example #21
Source File: main.py    From python-turtle-draw-svg with GNU General Public License v3.0 5 votes vote down vote up
def Bezier_2(x1, y1, x2, y2, x3, y3):  # 二阶贝塞尔函数
    te.goto(x1, y1)
    te.pendown()
    for t in range(0, WriteStep + 1):
        x = Bezier(Bezier(x1, x2, t / WriteStep),
                   Bezier(x2, x3, t / WriteStep), t / WriteStep)
        y = Bezier(Bezier(y1, y2, t / WriteStep),
                   Bezier(y2, y3, t / WriteStep), t / WriteStep)
        te.goto(x, y)
    te.penup()