def drawsquaresizable(squareme, width):
    squareme.fillcolor(randomcolor())  # fill the specified color in the shape
    squareme.begin_fill ()
    squareme.forward(width)
    squareme.left(90)
    squareme.forward(width)
    squareme.left(90)
    squareme.forward(width)
    squareme.left(90)
    squareme.forward(width)
    squareme.left(90)
    squareme.end_fill()
Ejemplo n.º 2
0
ninja = turtle.Turtle()
'''
If you set the speed to 10, the turtle will go really fast.
If you set the speed to 1, the turtle will go really slow (which is useful
  for trying to understand how some complicated thing is being drawn).
If you set the speed to zero, however, the turtle will go at warpspeed and
  will draw as fast as it can.
'''
ninja.speed(10)

for i in range(180):
    '''
    Change the pen color every 10 drawing lines
    '''
    if ((i % 10) == 0):
        ninja.pencolor(randomcolor())

    ninja.forward(100)
    ninja.right(30)
    ninja.forward(20)
    ninja.left(60)
    ninja.forward(50)
    ninja.right(30)

    ninja.penup()
    '''
    This sets the turtle’s position to the coordinates (0, 0).
      (0, 0) is located at the center of the screen ehere
      the turtle first started.
    Note that you need to make sure the turtle’s pen is up,
      otherwise it will draw a line back to that.
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
import turtle
from colors import randomcolor


seurat = turtle.Turtle()

dot_distance = 20
width = 10
height = 8

seurat.penup()

for y in range(height):
    for i in range(width):
        seurat.pencolor(randomcolor())
        seurat.dot()
        seurat.forward(dot_distance)
    seurat.backward(dot_distance * width)
    seurat.right(90)
    seurat.forward(dot_distance)
    seurat.left(90)


turtle.done()