Ejemplo n.º 1
0
def prepareCoordinates():
  turtle2.pauseDrawing()
  t = turtle2.Turtle()
  t.color("#545454")
  t.hideturtle()
  t.speed(0)
  t.penup()
  drawAxis(t, -600, 0)
  t.right(270)
  drawAxis(t, 0, -600)
  drawTicksX(t, -600)
  t.right(270)
  drawTicksY(t, -600)
  drawXnumbers(t, -600)
  drawYnumbers(t, -600)
  turtle2.unpauseDrawing()
Ejemplo n.º 2
0
def prepareCoordinates():
    turtle2.pauseDrawing()
    t = turtle2.Turtle()
    t.color("#545454")
    t.hideturtle()
    t.speed(0)
    t.penup()
    drawAxis(t, -600, 0)
    t.right(270)
    drawAxis(t, 0, -600)
    drawTicksX(t, -600)
    t.right(270)
    drawTicksY(t, -600)
    drawXnumbers(t, -600)
    drawYnumbers(t, -600)
    turtle2.unpauseDrawing()
Ejemplo n.º 3
0
def draw_block(x, y, color=(255, 0, 0), size=30):
    turtle2.pauseDrawing()
    t = turtle2.Turtle()
    t.speed("fastest")
    t.hideturtle()
    t.penup()
    t.goto(x, y)
    t.setheading(90)
    t.pendown()

    # The right side
    t.fillcolor(blend_colors(color, (0, 0, 0)))
    t.begin_fill()
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.end_fill()

    # The left side
    t.fillcolor(blend_colors(color, (0, 0, 0), weight1=3.0))
    t.begin_fill()
    t.right(60)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.end_fill()

    # The top side
    t.fillcolor(color)
    t.begin_fill()
    t.right(180)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.end_fill()

    turtle2.unpauseDrawing()
Ejemplo n.º 4
0
def piirra_kuutio(x, y, vari=(255, 0, 0), koko=30):
    turtle2.pauseDrawing()
    t = turtle2.Turtle()
    t.speed("fastest")
    t.hideturtle()
    t.penup()
    t.goto(x, y)
    t.setheading(90)
    t.pendown()

    # Oikea puoli
    t.fillcolor(sekoita_varit(vari, (0, 0, 0)))
    t.begin_fill()
    t.forward(koko)
    t.right(60)
    t.forward(koko)
    t.right(120)
    t.forward(koko)
    t.right(60)
    t.forward(koko)
    t.end_fill()

    # Vasen puoli
    t.fillcolor(sekoita_varit(vari, (0, 0, 0), paino1=3.0))
    t.begin_fill()
    t.right(60)
    t.forward(koko)
    t.right(60)
    t.forward(koko)
    t.right(120)
    t.forward(koko)
    t.end_fill()

    # Yläpuoli
    t.fillcolor(vari)
    t.begin_fill()
    t.right(180)
    t.forward(koko)
    t.right(120)
    t.forward(koko)
    t.right(60)
    t.forward(koko)
    t.end_fill()

    turtle2.unpauseDrawing()
Ejemplo n.º 5
0
def draw_block(x, y, color=(255, 0, 0), size=30):
    turtle2.pauseDrawing()
    t = turtle2.Turtle()
    t.speed("fastest")
    t.hideturtle()
    t.penup()
    t.goto(x, y)
    t.setheading(90)
    t.pendown()

    # The right side
    t.fillcolor(blend_colors(color, (0, 0, 0)))
    t.begin_fill()
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.end_fill()

    # The left side
    t.fillcolor(blend_colors(color, (0, 0, 0), weight1=3.0))
    t.begin_fill()
    t.right(60)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.end_fill()

    # The top side
    t.fillcolor(color)
    t.begin_fill()
    t.right(180)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.end_fill()

    turtle2.unpauseDrawing()
Ejemplo n.º 6
0
def piirra_kuutio(t, x, y, color=(255, 0, 0), size=50):
    turtle2.pauseDrawing()
    t.speed("fastest")
    t.hideturtle()
    t.penup()
    t.goto(x, y)
    t.setheading(90)
    t.pendown()

    # Oikea puoli
    t.fillcolor(sekoita_varit(color, (0, 0, 0)))
    t.begin_fill()
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.end_fill()

    # Vasen puoli
    t.fillcolor(sekoita_varit(color, (0, 0, 0), weight1=3.0))
    t.begin_fill()
    t.right(60)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.end_fill()

    # Yläpuoli
    t.fillcolor(color)
    t.begin_fill()
    t.right(180)
    t.forward(size)
    t.right(120)
    t.forward(size)
    t.right(60)
    t.forward(size)
    t.end_fill()

    turtle2.unpauseDrawing()
Ejemplo n.º 7
0

# Generate obstacles at random locations by calling the helper
# functions defined above.

screen = turtle2.Screen()
right = min(250, screen.window_width() / 2 - 5)
left = -right
top = min(270, screen.window_height() / 2 - 5)
bottom = -top

obstacles = (outerBounds(left, right, top, bottom) +
             generateObstacles(4, left, right, top - 20, bottom + 60))

# Draw the obstacles
turtle2.pauseDrawing()
drawRectangles(obstacles)
drawFinishLine(left, right, top)
turtle2.unpauseDrawing()

# Create the turtle
t = turtle2.Turtle()
t.speed("fastest")
t.penup()
t.goto((left + right) / 2, bottom + 20)
t.setheading(90)
t.pendown()

# This loop moves the turtle one step at a time until it reaches the
# top.
startTime = time.time()
Ejemplo n.º 8
0
  t.forward(10)

# Generate obstacles at random locations by calling the helper
# functions defined above.

screen = turtle2.Screen()
right = min(250, screen.window_width()/2 - 5)
left = -right
top = min(270, screen.window_height()/2 - 5)
bottom = -top

obstacles = (outerBounds(left, right, top, bottom) +
             generateObstacles(4, left, right, top - 20, bottom + 60))

# Draw the obstacles
turtle2.pauseDrawing()
drawRectangles(obstacles)
drawFinishLine(left, right, top)
turtle2.unpauseDrawing()

# Create the turtle
t = turtle2.Turtle()
t.speed("fastest")
t.penup()
t.goto((left + right)/2, bottom + 20)
t.setheading(90)
t.pendown()

# This loop moves the turtle one step at a time until it reaches the
# top.
startTime = time.time()