Exemplo n.º 1
0
 def test_rotation(self):
     t = Turtle()
     self.assertEqual(t.rotation, 0)
     t.right(30)
     self.assertEqual(t.rotation, 30)
     t.left(30)
     self.assertEqual(t.rotation, 0)
Exemplo n.º 2
0
 def test_rotation(self):
     t = Turtle()
     self.assertEqual(t.rotation, 0)
     t.right(30)
     self.assertEqual(t.rotation, 30)
     t.left(30)
     self.assertEqual(t.rotation, 0)
Exemplo n.º 3
0
def goldenratio2drawille(goldenratio, n, s, angle):
    def square(size):
        for i in range(4):
            t.forward(size)
            t.right(goldenratio.angle)

    # Taken from python turtle library
    def circle(radius, extent=None, steps=None):
        fullCircle = 360
        if extent is None:
            extent = fullCircle
        if steps is None:
            frac = abs(extent) / fullCircle
            steps = 1+int(min(11+abs(radius) / 6.0, 59.0)*frac)
        w = 1.0 * extent / steps
        w2 = 0.5 * w
        l = 2.0 * radius * sin(w2*pi/180.0)
        if radius < 0:
            l, w, w2 = -l, -w, -w2
        t.right(w2)
        for i in range(steps):
            t.forward(l)
            t.right(w)
        t.left(w2)

    t = Turtle()
    size = getTerminalSize()[0] + s
    t.rotation = goldenratio.angle + angle

    for i in range(n):
        square(size)
        t.forward(size)
        t.right(goldenratio.angle)
        t.forward(size)
        size /= goldenratio.phi

    t.up()
    t.move(0, 0)
    t.down()
    size = getTerminalSize()[0] + s
    t.rotation = goldenratio.angle + angle

    for i in range(n):
        circle(size, 90)
        size /= goldenratio.phi

    return t.frame()
Exemplo n.º 4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from drawille import Turtle

t = Turtle()

for _ in range(36):
    t.right(10)
    for _ in range(36):
        t.right(10)
        t.forward(8)

print(t.frame())