-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.py
More file actions
83 lines (71 loc) · 2.17 KB
/
Copy pathA.py
File metadata and controls
83 lines (71 loc) · 2.17 KB
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
82
83
import turtle
import math
import random
def setup_turtle():
"""Sets up the initial drawing environment."""
screen = turtle.Screen()
screen.setup(width=800, height=600)
screen.title("Algorithmic Calligraphy")
screen.colormode(255) # Use RGB for dynamic colors
t = turtle.Turtle()
t.speed(0) # Fastest drawing speed
t.hideturtle()
t.penup()
t.goto(-300, 0)
t.pendown()
return t
def draw_innovative_A(t):
"""Draws the letter 'A' using a spiral-like, dynamic pattern."""
# 1. Start with an initial position and color
t.pensize(2)
start_color = (255, 0, 100) # Hot Pink
t.pencolor(start_color)
t.setheading(60) # Start angled up
# Points for the crossbar
crossbar_start = None
crossbar_end = None
# 2. Draw the left leg of the 'A'
t.pendown()
for i in range(50):
r = int(255 * (1 - i / 100))
g = int(255 * (i / 100))
b = 100
t.pencolor(r, g, b)
t.forward(5 + i * 0.05)
t.left(2)
if i == 25:
crossbar_start = t.pos()
# 3. Move to the top point and rotate for the right leg
t.right(180 - (50 * 2) - 120)
# 4. Draw the right leg of the 'A'
for i in range(50):
r = int(150 + 105 * (i / 100))
g = int(255 - 255 * (i / 100))
b = int(100 - 100 * (i / 100))
t.pencolor(r, g, b)
t.forward(10 - i * 0.05)
t.right(2)
if i == 25:
crossbar_end = t.pos()
# 5. Draw the crossbar with a gradient
if crossbar_start and crossbar_end:
t.penup()
t.goto(crossbar_start)
t.pendown()
# Calculate the distance and angle for the crossbar
distance = t.distance(crossbar_end)
t.setheading(t.towards(crossbar_end))
steps = 50
for i in range(steps):
# Gradient from blue to green
r = int(0)
g = int(255 * (i / steps))
b = int(255 * (1 - i / steps))
t.pencolor(r, g, b)
t.forward(distance / steps)
# Final cleanup
t.penup()
if __name__ == "__main__":
artist = setup_turtle()
draw_innovative_A(artist)
turtle.done()