repl.it
Python (with Turtle)

jess's repl.it

fork
loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Reference: https://www.eg.bucknell.edu/~hyde/Python3/TurtleDirections.html

import turtle
from random import randint as rint

wn = turtle.Screen()
wn.bgcolor("black")

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

''' Draw spiral. Alter angle to get some interesting shapes'''

angle = 193
side = 10
inc = 2

t.penup()
t.goto(0, 0)
t.pendown()
for i in range(500):
colour_vaules(rint(0, 255), rint(0, 255) rint, (0, 255))
  t.pencolor(colour_values)
  t.forward(side)
  t.left(angle)
  side = side + inc



###################### Functions #################################

def draw_square(t, side, thickness, colour):
  '''
  This function draws a square with a sidelength of side, a line
  thickness of thickness, and a colour of colour
  '''
  t.pendown()
  t.setheading(0)
  t.color(colour)
  t.width(thickness)
  for i in range(4):
    t.forward(side)
    t.left(90)
  t.penup()

# draw_square(t, 100, 8, "red")


def draw_shape(t, num_sides, side, thickness, colour):
  '''
  This function draws a multi-sided shape
  '''
  t.pendown()
  t.setheading(0)
  t.pencolor(colour)
  t.width(thickness)
  angle = 360 / num_sides
  for i in range(num_sides):
    t.forward(side)
    t.left(angle)
  t.penup()



# Draw a series of 10 sided shapes
# t.penup()
# t.goto(-100, -195)

# wn = turtle.Screen()
# wn.bgcolor("black")

# side = 10
# inc = 2
# for i in range(70):
#   # Geherate a random colour tuple
#   colour_values = (rint(0, 255), rint(0, 255), rint(0, 255))
#   draw_shape(t, 10, side, 2, colour_values)
#   side += inc

  
result
console
?