Saturday, January 7, 2023

Python Turtle Graphics Drawing - New Balance Logo

Python Turtle Graphics Drawing - New Balance Logo

Featuring: 

Bézier curve

Youtube


Source code:

from turtle import *
from math import atan2,degrees

setup(500,500)
speed('slowest')

def cbezto(b,c,d):
    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)


RED = '#E21836'

up()
lt(180)
fd(180)
down()
color(RED)
begin_fill()
rt(119.9)
fd(206.5)
rt(60.1)
fd(68.5)
rt(75.5)
fd(66.1)
lt(135.8)
fd(73.7)
rt(60.3)
fd(103.5)
cbezto((220,178),(195.5,105),(138.5,90.5))
cbezto((191,75),(152,0),(70,0))
rt(5.3)
fd(112)
rt(75.4)
fd(65.6)
lt(135.9)
fd(73)
rt(60.4)
fd(85.5)
end_fill()

color('white')
up()
rt(158.8)
fd(304.6)
down()
begin_fill()
lt(158.8)
fd(17.5)
rt(119.8)
fd(39.2)
rt(60.2)
fd(17.5)
cbezto((140.5,140),(132.5,109.5),(104,110))
end_fill()

up()
lt(57.8)
fd(38.7)
down()
begin_fill()
rt(63.1)
fd(20)
lt(60)
fd(41)
lt(120)
fd(21)
cbezto((98,41),(106.5,73.5),(86.5,75.5))
end_fill()

up()
rt(10.9)
fd(198.3)
down()
begin_fill()
rt(157.1)
fd(177.4)
rt(115.9)
fd(4)
rt(56.7)
fd(191.9)
rt(124.5)
fd(32.1)
end_fill()

up()
rt(176.4)
fd(46.7)
down()
begin_fill()
lt(113.8)
fd(175.8)
rt(118.4)
fd(4.7)
rt(54.4)
fd(189.4)
rt(124.3)
fd(31.4)
end_fill()


up()
lt(179.3)
fd(48)
down()
begin_fill()
lt(117.8)
fd(176.8)
rt(116.2)
fd(4)
rt(56.5)
fd(189.9)
rt(122.8)
fd(30.9)
end_fill()

up()
lt(179.2)
fd(47.3)
down()
begin_fill()
lt(116.4)
fd(177.3)
rt(122.1)
fd(4.3)
rt(50.4)
fd(191)
rt(124.2)
fd(31.8)
end_fill()
up()
fnt = ('Century Gothic', 54,'bold')
color(RED)
goto(0,-85)
write('new balance',font=fnt,align='center')
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 (...