Tuesday, February 13, 2024

Python Turtle Graphics Drawing - WALL'S Logo

Python Turtle Graphics Drawing - WALL'S Logo

Youtube


Source code:

from turtle import *
from math import atan2,degrees

LOGO = [
    [-68,11.6],[-117.6,44.9],[-105,90],[-85.7,133.8],
    [-29.3,118],[-6,75],[-2.6,69.5],[1.9,71.1],[6.2,77.5],
    [45.7,133.4],[97.9,122],[106,77],[114.2,6.9],
    [45.2,-38.6],[0,-48],[-82.9,-44.8],[-188.1,-1.9],
    [-221,63],[-251.2,144.1],[-191.8,184.4],[-121,189],
    [-71.9,189.4],[-32.8,173.8],[-6.5,151.9],[-1.4,147.1],
    [2.4,148.7],[5.9,151.9],[95.5,212.5],[180.4,186.6],
    [212,141],[263.5,63.7],[172.5,-15.9],[131.9,-45.1],
    [114.9,-56.4],[121.3,-62.1],[135.8,-55.4],[251.4,-11.3],
    [291,70.7],[273,140],[234.8,246.2],[83.6,247.4],
    [5.6,188.1],[0.5,183.8],[-2.5,184.2],[-7,187.6],
    [-93.7,250.3],[-222.9,234],[-259,178],[-306.9,105.2],
    [-263,19.8],[-155,-37],[-90.9,-66.1],[-42.8,-75.6],
    [0,-78],[109.5,-53],[176.7,41.3],[157,99],[138.8,165],
    [64.6,162.7],[6.2,113.8],[-0.4,107],[-3,108.1],[-8,114],
    [-50.1,159.4],[-118.8,167.2],[-156,121],[-183.2,78],
    [-149.2,31.5],[-100,9],[-68.9,-8.2],[-37.7,-16.4],
    [-11,-18],[-3.7,-19.3],[-2.9,-12.6],[-10,-11],
]

S1 = [
    [215.5,-206.2],[227.3,-207.7],[231.5,-197.2],
    [233.6,-186.6],[220.5,-183.9],[213.5,-181.6],
    [188.5,-173],[188.2,-150.3],[194,-138],
    [204.3,-113.3],[237.2,-113],[253,-137],
]

S2 = [
    [228.7,-139.9],[218.7,-140],[214.6,-145.3],
    [207.7,-157.1],[220.3,-161],[230,-164],
    [260.5,-173.1],[256.5,-205.7],[242.8,-218.7],
    [229.9,-230.8],[204.3,-230.4],[190,-209],
]

def cbezto(b,c,d):
    speed(150)
    a=pos()
    t = 0.0
    while t <= 1.0:
        t3 = t**3
        t2 = t**2
        f1 = -t3+3*t2-3*t+1
        f2 = 3*t3-6*t2+3*t
        f3 = -3*t3+3*t2
        f4 = t3
        x = a[0]*f1 + b[0]*f2 + c[0]*f3 + d[0]*f4
        y = a[1]*f1 + b[1]*f2 + c[1]*f3 + d[1]*f4
        d1 = -3*t2+6*t-3
        d2 = 9*t2-12*t+3
        d3 = -9*t2+6*t
        d4 = 3*t2
        dx = a[0]*d1 + b[0]*d2 + c[0]*d3 + d[0]*d4
        dy = a[1]*d1 + b[1]*d2 + c[1]*d3 + d[1]*d4
        angr = atan2(dy, dx)
        seth(degrees(angr))
        goto(x, y)
        t += 0.05
    goto(d)
    speed(5)

def L():
    begin_fill()
    fd(22)
    rt(90)
    fd(82)
    lt(90)
    fd(34)
    rt(90)
    fd(22)
    rt(90)
    fd(56)
    rt(90)
    fd(104)
    end_fill()


setup(640,640)
speed(5)
color('red')
shape('turtle')
up()
rt(132.3)
fd(14.9)
down()
begin_fill()
for i in range(len(LOGO)//3):
    cbezto(LOGO[i*3],LOGO[i*3+1],LOGO[i*3+2])
end_fill()

#W
up()
lt(43.5)
fd(269.7)
down()
begin_fill()
rt(178.7)
fd(22.4)
rt(95.9)
fd(65.2)
lt(137.9)
fd(65.6)
rt(138.2)
fd(66.1)
lt(138.5)
fd(66.5)
rt(96.6)
fd(21.5)
rt(85.1)
fd(110.7)
rt(134.3)
fd(61.8)
lt(134.3)
fd(61.8)
rt(134.8)
fd(110.3)
end_fill()

#A
up()
rt(147.5)
fd(161.5)
down()
begin_fill()
lt(98.8)
fd(114.9)
rt(127.1)
fd(114)
rt(88.8)
fd(21.5)
rt(90)
fd(21.5)
lt(62.2)
fd(45)
lt(68.2)
fd(21.5)
rt(94.8)
fd(22.4)
end_fill()

#A
up()
lt(255.7)
fd(78)
down()
color('white')
begin_fill()
rt(163.3)
fd(31.8)
lt(114.1)
fd(25)
lt(112.5)
fd(31.4)
end_fill()

color('red')
#L
up()
rt(84)
fd(81.9)
down()
rt(28.4)
L()
#L
up()
lt(270)
fd(80)
down()
L()
#S
up()
lt(231.1)
fd(140.1)
down()
begin_fill()
lt(83.5)
fd(21.8)
for i in range(4):
    cbezto(S1[i*3],S1[i*3+1],S1[i*3+2])
rt(83.9)
fd(22.6)
for i in range(4):
    cbezto(S2[i*3],S2[i*3+1],S2[i*3+2])
end_fill()

# '
up()
lt(2.4)
fd(71.6)
down()
begin_fill()
rt(61.9)
fd(44.9)
rt(96.9)
fd(21.5)
rt(90.5)
fd(44.3)
rt(88.3)
fd(15.7)
end_fill()
hideturtle()
done()

No comments:

Post a Comment

Python Turtle Graphics Drawing - Gigabyte

 Python Turtle Graphics Drawing - Gigabyte Youtube Source code: from turtle import * setup ( 600 , 600 ) color ( '#2D68AE' ) up (...