Esempio n. 1
0
def draw_shape(t):
    # large circle
    circle(t, 100)

    # 4 triangles
    move(t, 0, 100)
    t.setheading(60)
    polygon(t, 3, 100)
    t.setheading(150)
    polygon(t, 3, 100)
    t.setheading(240)
    polygon(t, 3, 100)
    t.setheading(330)
    polygon(t, 3, 100)

    # 4 small circles
    moving_step = 50 * math.sqrt(3)
    small_radius = 50 * math.sqrt(3) / 3

    move(t, 0, 100 - moving_step)
    t.setheading(0)
    circle(t, small_radius)

    move(t, moving_step, 100)
    t.setheading(90)
    circle(t, small_radius)

    move(t, 0, 100 + moving_step)
    t.setheading(180)
    circle(t, small_radius)

    move(t, -moving_step, 100)
    t.setheading(270)
    circle(t, small_radius)
Esempio n. 2
0
def circle_triangle(t, r):
    """
    Draws a pattern of circles within triangles within circle, 
    t is a turtle, r is the radius of the outter circle 
    """
    # draws the big circle
    circle(t, r)

    # draws the four triangles
    move(t, 0, r)
    t.lt(60)
    for _ in range(4):
        t.lt(90)
        polygon(t, r, 3)

    # calculations for small circles
    degree30 = math.radians(30)
    degree60 = math.radians(60)
    r_s = r / 2 / math.tan(degree60)
    height = r * math.cos(degree30)

    # draws the bottom small circle
    y1 = 100 - height
    move(t, 0, y1)
    t.rt(60)
    circle(t, r_s)

    # draws the top small circle
    y2 = 100 + height
    move(t, 0, y2)
    t.lt(180)
    circle(t, r_s)

    #draws the left small circle
    x1 = -height
    move(t, x1, r)
    t.lt(90)
    circle(t, r_s)

    # draws the right small circle
    x2 = height
    move(t, x2, r)
    t.lt(180)
    circle(t, r_s)
Esempio n. 3
0
from turtle_shape import arc, circle, move, polygon
import turtle
import math

# 3.1.1

alex = turtle.Turtle()
alex.speed(0)

# large circle
circle(alex, 100)

# 4 triangles
move(alex, 0, 100)
alex.setheading(60)
polygon(alex, 3, 100)
alex.setheading(150)
polygon(alex, 3, 100)
alex.setheading(240)
polygon(alex, 3, 100)
alex.setheading(330)
polygon(alex, 3, 100)

# 4 small circles
moving_step = 50 * math.sqrt(3)
small_radius = 50 * math.sqrt(3) / 3

move(alex, 0, 100 - moving_step)
alex.setheading(0)
circle(alex, small_radius)
Esempio n. 4
0
from turtle_shape import arc, circle, move, polygon
import turtle
import math

# 3.1.1

jerry = turtle.Turtle()
jerry.speed(0)

# large circle
circle(jerry, 100)

# 4 triangles
move(jerry, 0, 100)
jerry.setheading(60)
polygon(jerry, 3, 100)
jerry.setheading(150)
polygon(jerry, 3, 100)
jerry.setheading(240)
polygon(jerry, 3, 100)
jerry.setheading(330)
polygon(jerry, 3, 100)

# 4 small circles
moving_step = 50 * math.sqrt(3)
small_radius = 50 * math.sqrt(3) / 3

move(jerry, 0, 100 - moving_step)
jerry.setheading(0)
circle(jerry, small_radius)
Esempio n. 5
0
import turtle
from turtle_shape import arc, circle, move, polygon
import math

# 3.1.1

lucky = turtle.Turtle()
lucky.speed(0)

# large circle
circle(lucky, 100)

# 4 triangles here we are printing the four triangles in the assigned different angles
move(lucky, 0, 100)
lucky.setheading(60)
polygon(lucky, 3, 100)
lucky.setheading(150)
polygon(lucky, 3, 100)
lucky.setheading(240)
polygon(lucky, 3, 100)
lucky.setheading(330)
polygon(lucky, 3, 100)


# 4 small circles same thing except with the four different circles 
moving_step = 50 * math.sqrt(3)
small_radius = 50 * math.sqrt(3) / 3

move(lucky, 0, 100 - moving_step)
lucky.setheading(0)
circle(lucky, small_radius)
Esempio n. 6
0
from turtle_shape import arc, circle, move, polygon
import turtle
import math

# 3.1.1

jack = turtle.Turtle()
jack.speed(0)

# large circle
circle(jack, 100)

# 4 triangles
move(jack, 0, 100)
jack.setheading(60)
polygon(jack, 3, 100)
jack.setheading(150)
polygon(jack, 3, 100)
jack.setheading(240)
polygon(jack, 3, 100)
jack.setheading(330)
polygon(jack, 3, 100)

# 4 small circles
moving_step = 50 * math.sqrt(3)
small_radius = 50 * math.sqrt(3) / 3

move(jack, 0, 100 - moving_step)
jack.setheading(0)
circle(jack, small_radius)