Made an epic showcase website and API!
This commit is contained in:
parent
9e21e4dbdd
commit
1907fad7c5
89 changed files with 36444 additions and 3 deletions
29
projects/Day 18/README.md
Normal file
29
projects/Day 18/README.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Day 18 - Turtle & the Graphical User Interface (GUI)
|
||||
|
||||
- Developed various basic turtle graphics.
|
||||
- Spirograph, random walk, various polygons, dashed line, and square.
|
||||
- Formed a dot art based on Hirst artwork.
|
||||
|
||||
## Dot art
|
||||
|
||||

|
||||
|
||||
## Spirograph
|
||||
|
||||

|
||||
|
||||
## Random Walk
|
||||
|
||||

|
||||
|
||||
## Polygons
|
||||
|
||||

|
||||
|
||||
## Dashed Line
|
||||
|
||||

|
||||
|
||||
## Square
|
||||
|
||||

|
||||
66
projects/Day 18/day-18-start/main.py
Normal file
66
projects/Day 18/day-18-start/main.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
from turtle import Turtle, Screen, colormode
|
||||
from random import randint, choice
|
||||
|
||||
arrow = Turtle()
|
||||
|
||||
# Draw a square
|
||||
def square():
|
||||
for i in range(4):
|
||||
arrow.forward(100)
|
||||
arrow.right(90)
|
||||
|
||||
# square()
|
||||
|
||||
# Draw a dashed line
|
||||
def dashed_line():
|
||||
for i in range(20):
|
||||
arrow.forward(10)
|
||||
arrow.penup()
|
||||
arrow.forward(10)
|
||||
arrow.pendown()
|
||||
|
||||
# dashed_line()
|
||||
|
||||
# Draw a triangle, square, pentagon, hexagon, heptagon, octagon, nonagon, and decagon
|
||||
def polygons():
|
||||
colormode(255)
|
||||
for i in range(3, 11):
|
||||
angle = 360 / i
|
||||
color = (randint(0, 255), randint(0, 255), randint(0, 255))
|
||||
arrow.color(color)
|
||||
for j in range(1, i + 1):
|
||||
arrow.right(angle)
|
||||
arrow.forward(100)
|
||||
|
||||
# polygons()
|
||||
|
||||
# Random Walk (thickness, speed up turtle)
|
||||
def random_walk(steps):
|
||||
colormode(255)
|
||||
arrow.pensize(15)
|
||||
arrow.speed(0)
|
||||
for i in range(steps):
|
||||
color = (randint(0, 255), randint(0, 255), randint(0, 255))
|
||||
arrow.color(color)
|
||||
step_size = randint(0, 50)
|
||||
arrow.setheading(choice([0, 90, 180, 270]))
|
||||
arrow.forward(step_size)
|
||||
|
||||
# random_walk(1000)
|
||||
|
||||
# Spirograph
|
||||
def spirograph():
|
||||
colormode(255)
|
||||
arrow.speed(0)
|
||||
heading = 0
|
||||
for i in range(72):
|
||||
color = (randint(0, 255), randint(0, 255), randint(0, 255))
|
||||
arrow.color(color)
|
||||
arrow.circle(200)
|
||||
arrow.setheading(heading)
|
||||
heading += 5
|
||||
|
||||
# spirograph()
|
||||
|
||||
screen = Screen()
|
||||
screen.exitonclick()
|
||||
BIN
projects/Day 18/dot-art/colors_source.jpg
Normal file
BIN
projects/Day 18/dot-art/colors_source.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
72
projects/Day 18/dot-art/main.py
Normal file
72
projects/Day 18/dot-art/main.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# # Get color palette from an image
|
||||
# import colorgram
|
||||
|
||||
# color_list = []
|
||||
# colors = colorgram.extract('colors_source.jpg', 30)
|
||||
# for color in colors:
|
||||
# r = color.rgb.r
|
||||
# g = color.rgb.g
|
||||
# b = color.rgb.b
|
||||
# new_color = (r, g, b)
|
||||
# color_list.append(new_color)
|
||||
# print(color_list)
|
||||
|
||||
from turtle import Turtle, Screen, colormode
|
||||
import random
|
||||
|
||||
arrow = Turtle()
|
||||
|
||||
color_list = [
|
||||
(221, 144, 96),
|
||||
(165, 57, 88),
|
||||
(68, 84, 153),
|
||||
(100, 167, 208),
|
||||
(154, 66, 54),
|
||||
(109, 176, 128),
|
||||
(195, 76, 113),
|
||||
(209, 123, 155),
|
||||
(222, 90, 66),
|
||||
(233, 163, 188),
|
||||
(238, 223, 97),
|
||||
(107, 117, 187),
|
||||
(176, 184, 224),
|
||||
(141, 210, 221),
|
||||
(84, 95, 88),
|
||||
(163, 139, 49),
|
||||
(58, 173, 186),
|
||||
(67, 54, 96),
|
||||
(234, 171, 155),
|
||||
(166, 206, 188),
|
||||
(154, 35, 49),
|
||||
(91, 159, 124),
|
||||
(189, 27, 24),
|
||||
(65, 55, 64),
|
||||
(56, 49, 71),
|
||||
(71, 56, 49),
|
||||
]
|
||||
|
||||
# Set arrow starting position
|
||||
arrow.hideturtle()
|
||||
arrow.speed(0)
|
||||
arrow.penup()
|
||||
arrow.sety(-250)
|
||||
arrow.setx(-250)
|
||||
arrow.width(20)
|
||||
|
||||
# Create dots
|
||||
colormode(255)
|
||||
number_of_dots = 100
|
||||
for i in range(1, number_of_dots + 1):
|
||||
arrow.pendown()
|
||||
arrow.dot(20, random.choice(color_list))
|
||||
arrow.penup()
|
||||
arrow.forward(50)
|
||||
if i % 10 == 0:
|
||||
arrow.penup()
|
||||
arrow.backward(500)
|
||||
arrow.left(90)
|
||||
arrow.forward(50)
|
||||
arrow.right(90)
|
||||
|
||||
screen = Screen()
|
||||
screen.exitonclick()
|
||||
Loading…
Add table
Add a link
Reference in a new issue