Saturday, December 17, 2022

Python Turtle Graphics Drawing - Github Logo

 Python Turtle Graphics Drawing - Github Logo

Youtube


Source code:

from turtle import *
setup(500,500)

up()
goto(0,25)
lt(9.61)
fd(16.71)
down()

begin_fill()
rt(7.51)
circle(47.77,34.6)
lt(2.42)
circle(34.94,43.9)
rt(3.54)
circle(52.84,24.17)
lt(2.5)
circle(32.28,27.43)
rt(62.44)
circle(32.88,42.04)
lt(61.25)
circle(20.28,23.32)
lt(0.28)
circle(62.13,16.79)
rt(49.84)
circle(85.57,29.96)
rt(47.33)
circle(91.67,11.61)
lt(7.42)
circle(32.07,14.14)
lt(66.62)
circle(37.06,20.33)
lt(1.3)
circle(31.16,20.39)
rt(61.04)
circle(36.25,46.08)
rt(5.8)
circle(41.76,42.48)
lt(2.35)
circle(35.93,30.13)
lt(0.7)
circle(87.34,9.21)
rt(128.5)
circle(18.17,41.72)
rt(60.65)
circle(-21.53,52.26)
rt(4.41)
circle(-17.78,32.96)
lt(8.54)
circle(30.33,19.25)
lt(4.62)
circle(12.71,45.5)
lt(0.19)
circle(1.31,135.2)
rt(25.38)
circle(10.91,32.29)
rt(18.51)
circle(-29.42,28.11)
lt(1.92)
circle(18,63.42)
rt(2.11)
circle(41.48,20.29)
rt(103.62)
fd(16.31)
lt(4.19)
circle(-4.45,127.22)
lt(14.51)
circle(-86.74,20.7)
rt(0.29)
circle(-91.15,22.1)
lt(0.34)
circle(-86.48,55.38)
lt(0.35)
circle(-90.49,47.21)
lt(0.38)
circle(-86.05,33.74)
rt(1.49)
circle(-97.67,28.82)
rt(1.53)
circle(-89.23,76.59)
rt(0.91)
circle(-93.05,32.62)
lt(15)
circle(-5.67,55.71)
lt(2.64)
circle(-4.45,82.54)
lt(9.42)
fd(26.93)
lt(5.43)
circle(22.32,37.03)
end_fill()

#G
up()
lt(81.32)
fd(158.78)
down()
begin_fill()
lt(146.22)
fd(27)
rt(90)
fd(39.5)
rt(59.65)
circle(-45.3,46.4)
lt(1.84)
circle(-26.79,52.95)
rt(3.86)
circle(-68.82,37.96)
rt(2.43)
circle(-26.57,63.62)
lt(2.25)
circle(-61.38,16.11)
lt(2.44)
circle(-30.31,21.54)
rt(74.64)
fd(14.19)
rt(98.86)
circle(39.54,24.82)
rt(4.54)
circle(17.57,53.39)
lt(12.22)
circle(41.04,51.22)
lt(9.11)
circle(15.01,61.36)
rt(5.11)
circle(34.99,11.64)
lt(77.39)
fd(14.85)
lt(90)
fd(10.77)
rt(90)
fd(14.56)
end_fill()

#i
up()
rt(78.53)
fd(35.2)
down()
begin_fill()
rt(11.47)
fd(16.5)
rt(90)
fd(51)
rt(90)
fd(16.5)
rt(90)
fd(51)
end_fill()

up()
rt(64.8)
fd(9.39)
down()
begin_fill()
rt(25.2)
circle(9)
end_fill()

#t
up()
lt(26.03)
fd(23.93)
down()
begin_fill()
rt(26.03)
fd(15.5)
rt(90)
fd(14.5)
lt(90)
fd(11.5)
rt(90)
fd(13.5)
rt(90)
fd(11.5)
lt(90)
fd(20)
rt(2.23)
circle(5.47,90.39)
rt(4.9)
circle(15.59,24.38)
rt(107.63)
fd(12.03)
rt(69.07)
circle(-26.88,41.86)
rt(5.24)
circle(-14.58,65.75)
lt(1.93)
fd(23.5)
lt(90)
fd(8.5)
rt(90)
fd(11)
rt(76.76)
fd(8.73)
lt(76.76)
fd(15)
end_fill()

#h
up()
rt(75.17)
fd(35.17)
down()
begin_fill()
rt(14.83)
fd(16)
rt(90)
fd(28)
lt(90)
fd(21.5)
lt(90)
fd(28)
rt(90)
fd(16)
rt(90)
fd(74.5)
rt(90)
fd(16)
rt(90)
fd(32)
lt(90)
fd(21.5)
lt(90)
fd(32)
rt(90)
fd(16)
rt(90)
fd(74.5)
end_fill()

#u
up()
rt(111.23)
fd(64.9)
down()
begin_fill()
lt(21.23)
fd(16)
rt(90)
fd(34)
lt(4.25)
circle(6.68,40.78)
lt(11.42)
circle(7.04,41.31)
rt(3.38)
circle(17.42,27.71)
lt(57.91)
fd(36.75)
rt(90)
fd(16)
rt(90)
fd(51)
rt(90)
fd(10.75)
rt(77.91)
fd(3.58)
lt(111.68)
circle(-28.63,21.51)
lt(0.36)
circle(-33.82,25.24)
rt(1.9)
circle(-13.84,67.91)
lt(4.15)
circle(-19.55,15.02)
lt(3.3)
fd(35)
end_fill()

#b
up()
rt(125.35)
fd(81.23)
down()
begin_fill()
rt(75.2)
fd(4.27)
rt(69.44)
fd(10.75)
rt(90)
fd(74.5)
rt(90)
fd(16)
rt(90)
fd(25.5)
lt(120.83)
circle(-24.74,33.15)
lt(4.76)
circle(-16.55,44.61)
lt(1.03)
circle(-16.2,32.53)
lt(0.82)
circle(-43.56,18.41)
lt(2.57)
circle(-52.14,16.79)
lt(3.42)
circle(-16.6,55.5)
rt(5.46)
circle(-28.27,33.61)
lt(1.49)
circle(-19.75,26.46)
end_fill()

color('white')
up()
rt(54.46)
fd(33.19)
down()
begin_fill()
rt(55)
circle(-18.59,23.08)
lt(2.72)
circle(-8.66,36.87)
rt(5.38)
circle(-7.78,38.49)
rt(3.6)
circle(-35.95,28.49)
lt(5.86)
circle(-5.36,59.48)
rt(4.88)
circle(-13.73,29.19)
lt(2.89)
circle(-14.13,23.49)
end_fill()
hideturtle()
done()

Wednesday, December 14, 2022

Python Turtle Graphics Drawing - Apple Logo

 Python Turtle Graphics Drawing - Apple Logo

Youtube


Source code:

from turtle import *

setup(500,500)
speed('slowest')
up()
rt(27.36)
fd(157.08)
down()
begin_fill()
rt(171.93)
circle(-82.19,132.13)
lt(104.28)
circle(109.12,72.92)
lt(11.41)
circle(-27.79,74.7)
lt(10.71)
circle(92.97,114.31)
rt(4.33)
circle(214.88,56.27)
lt(9.06)
circle(47.44,64.75)
rt(7.45)
circle(-80.9,51.95)
rt(6.62)
circle(48.48,70.28)
lt(5.37)
circle(207.33,29.99)
end_fill()

up()
lt(56.69)
fd(247.13)
down()
begin_fill()
rt(40.82)
circle(-87.7,80.27)
rt(99.03)
circle(-86.46,81.67)
end_fill()
hideturtle()
done()

Monday, December 12, 2022

Python Turtle Graphics Drawing - LG Logo

 Python Turtle Graphics Drawing - LG Logo

Youtube


Source code:

from turtle import *

setup(500,500)
shape('turtle')

up()
fd(200)
down()
lt(90)
color('#C4084F')
begin_fill()
circle(200)
end_fill()

up()
color('white')
lt(75.1)
fd(248.4)
down()
rt(75.3)
begin_fill()
circle(24.1)
end_fill()

up()
rt(52.9)
fd(40)
down()
begin_fill()
rt(36.9)
fd(16)
rt(90)
fd(160)
lt(90)
fd(39)
rt(90)
fd(15)
rt(90)
fd(55)
rt(90)
fd(175)
end_fill()

up()
rt(145)
fd(97.7)
down()
begin_fill()
lt(55)
fd(119)
rt(87.3)
circle(-167.1,275.4)
rt(87.3)
fd(15)
rt(93.2)
circle(151.6,269.9)
lt(93.3)
fd(103)
rt(90)
fd(16)
end_fill()

hideturtle()
done()

Sunday, December 11, 2022

Python Turtle Drawing - C++ Logo

 Python Turtle Drawing - C++ Logo

Youtube


Source code:

from turtle import *

setup(500,500)
C1 = '#659AD2'
C2 = '#00599C'
C3 = '#004482'
color(C1)
begin_fill()
lt(29.94)
fd(240.11)
lt(89.1)
circle(39.33,27.6)
lt(3.44)
fd(207.34)
lt(8.32)
circle(42.38,43.19)
lt(8.35)
fd(201.55)
rt(3.73)
circle(41.81,63.22)
lt(0.57)
fd(199.3)
lt(1.22)
circle(43.04,28.26)
lt(90.56)
fd(240.29)
end_fill()

color(C2)
begin_fill()
rt(60.08)
fd(240.37)
lt(89.04)
circle(38.3,26.57)
lt(4.44)
fd(205.5)
lt(2.16)
circle(37.3,29.01)
lt(88.77)
fd(240.11)
end_fill()

color(C3)
begin_fill()
lt(0.1)
fd(240.29)
lt(90.21)
circle(42.86,35.06)
rt(5.23)
fd(196.74)
lt(3.54)
circle(41.33,52.75)
lt(3.57)
fd(205.39)
lt(4.52)
circle(38.08,26.47)
lt(89.03)
fd(240.37)
end_fill()

color('white')
up()
rt(120.02)
fd(142.26)
down()
begin_fill()
lt(90)
circle(142.26,300.02)
up()
rt(145.22)
fd(0.02)
down()
rt(124.79)
fd(71.02)
lt(90.01)
circle(-71.25,300.02)
up()
lt(128.85)
fd(0.01)
down()
rt(38.86)
fd(71)
end_fill()

begin_fill()
up()
lt(225.01)
fd(49.18)
down()
lt(105.06)
fd(16)
rt(90)
fd(15.5)
lt(90)
fd(16)
rt(90)
fd(16)
rt(90)
fd(16)
lt(90)
fd(16)
rt(90)
fd(16)
rt(90)
fd(16)
lt(90)
fd(15.5)
rt(90)
fd(16)
rt(90)
fd(15.5)
lt(90)
fd(15.5)
end_fill()

up()
rt(90)
fd(59.5)
down()
begin_fill()
fd(16)
lt(270)
fd(15.5)
lt(90)
fd(15.5)
rt(90)
fd(16)
rt(90)
fd(15.5)
lt(90)
fd(16)
rt(90)
fd(16)
rt(90)
fd(16)
lt(90)
fd(16)
rt(90)
fd(16)
rt(90)
fd(16)
lt(90)
fd(15.5)
end_fill()

hideturtle()
done()

Python Turtle Graphics Drawing - Python Logo

Python Turtle Graphics Drawing - Python Logo

Youtube


Source code:

from turtle import *

speed('slowest')
pensize(2)
shape('turtle')
setup(500,500)
bgcolor('#E6E6E6')

pencolor('#174163')
fillcolor('#306998')
up()
lt(121.83)
fd(170.66)
down()

begin_fill()
rt(31.83)
fd(51)
rt(11.76)
circle(-36.87,70.3)
lt(4.13)
circle(-271.31,25.12)
rt(12.3)
circle(-60.97,39.31)
rt(25.35)
fd(92)
lt(9.17)
circle(-46.58,99.2)
lt(0.02)
fd(87)
rt(1.15)
circle(52.94,90.15)
lt(1.01)
fd(44)
rt(90)
fd(37)
rt(6.43)
circle(-50.8,67.01)
lt(2.46)
circle(-165.66,38.05)
rt(1.35)
circle(-58.31,68.98)
rt(0.65)
fd(125)
lt(90)
fd(10)
lt(90)
fd(90)
end_fill()

fillcolor('white')
up()
rt(144.94)
fd(69.63)
down()
lt(54.94)
begin_fill()
circle(17.5)
end_fill()

pencolor('#65551C')
fillcolor('#FFD43B')
up()
rt(110.22)
fd(141.74)
down()
begin_fill()
lt(20.22)
fd(41)
rt(11.04)
circle(-41.77,67.92)
lt(10.44)
circle(-158.41,42.96)
lt(9.23)
circle(-44.61,73.13)
rt(4.62)
fd(134)
lt(90)
fd(10)
lt(90)
fd(88)
rt(90)
fd(38)
rt(1.65)
circle(-38.32,58.11)
rt(2.2)
circle(-146.74,56.1)
lt(1.43)
circle(-38.15,60.22)
rt(3.17)
fd(96)
rt(9.27)
circle(-45.63,74.39)
rt(6.34)
fd(94)
lt(3.98)
circle(63.4,68.35)
lt(17.67)
fd(54)
end_fill()
fillcolor('white')
up()
lt(171.73)
fd(236.46)
down()
rt(171.73)
begin_fill()
circle(16)
end_fill()

pencolor('#A0A0A0')
fillcolor('#BEBEBE')
up()
lt(141.17)
fd(105.26)
down()
begin_fill()
lt(126.75)
fd(55.04)
rt(6.45)
fd(40.45)
rt(12.03)
fd(25.63)
rt(18.1)
fd(6.4)
rt(51.34)
fd(5)
rt(51.34)
fd(6.4)
rt(18.1)
fd(25.63)
rt(12.03)
fd(40.45)
rt(6.45)
fd(55.04)
rt(5.26)
fd(54.08)
rt(4.95)
fd(35.36)
rt(13.24)
fd(24.7)
rt(23.63)
fd(5.66)
rt(45)
fd(4)
rt(45)
fd(5.66)
rt(23.63)
fd(24.7)
rt(13.24)
fd(35.36)
rt(3.89)
fd(54.15)
end_fill()
hideturtle()
done()

Friday, December 9, 2022

Twisted Square Animation - Python Turtle Graphics

 Twisted Square Animation - Python Turtle Graphics

Youtube


Source code:

from turtle import *
from math import atan2,degrees
import colorsys as cs

setup(500,500)
bgcolor('black')
R = 150
tur = (Turtle(),Turtle(),Turtle(),Turtle())
tracer(0,0)
M = 0.001
color('white')
cols=['red','green','orange','cyan']
up()
dM = 0.0005
hh = 0
hideturtle()
while True:
    h = hh
    clear()
    for i in range(4):
        tur[i].hideturtle()
        tur[i].up()
        tur[i].color(cols[i])
        tur[i].clear()
    tur[0].goto(-R,R)
    tur[1].goto(R,R)
    tur[2].goto(R,-R)
    tur[3].goto(-R,-R)
    tur[0].seth(0)
    tur[1].seth(-90)
    tur[2].seth(180)
    tur[3].seth(90)
    r=R*2
    for i in range(20):
        color(cs.hsv_to_rgb(h,1,1))
        goto(tur[0].pos())
        down()
        goto(tur[1].pos())
        goto(tur[2].pos())
        goto(tur[3].pos())
        goto(tur[0].pos())
        up()
        a = degrees(atan2(M*r,r-M*r))
        for j in range(4):
            tur[j].fd(M*r)
            tur[j].rt(a)
        r=r-M*r
        h = h+0.025
    update()
    hh = hh+0.0025
    M=M+dM
    if M>=0.2 or M<=-0.1:
        dM=-dM
        dM=dM*1.25

done()

Wednesday, December 7, 2022

Cardioid Animation - Python Turtle Graphics

 Cardioid Animation - Python Turtle Graphics

Youtube


Source code:

from turtle import *
from math import sin,cos,radians
import colorsys as cs

setup(500,500)
bgcolor('black')
R = 200
def getpt(n):
    n = (360/N*n)%360
    a=radians(n)
    x = -cos(a)*R
    y = sin(a)*R
    return (x,y)

tracer(0,0)
hideturtle()
F = 1
for N in range(4,300):
    clear()
    up()
    goto(R,0)
    seth(90)
    down()
    color('white')
    circle(R)
    up()
    h=0
    for i in range(N):
        h = i/(N*3)
        color(cs.hsv_to_rgb(h,1,1))
        c = getpt(i)
        d = getpt(i*F)
        goto(c)
        down()
        goto(d)
        up()
    update()
    F = F+1/295

done()

Tuesday, December 6, 2022

Python Turtle Graphics Drawing - Heart

 Python Turtle Graphics Drawing - Heart

Youtube


Formula reference:

https://mathworld.wolfram.com/HeartCurve.html

Source code:

from turtle import *
from math import sin,cos,radians
setup(640,640)
R = 15
color('#f0a')
up()
begin_fill()
for i in range(360):
    a = radians(i)
    x = R*16*sin(a)**3
    y = R*(13*cos(a)-5*cos(2*a)\
        -2*cos(3*a)-cos(4*a))
    goto(x,y)
    down()
end_fill()
done()

Sunday, December 4, 2022

Python Turtle Graphics Drawing - Lego® Logo

 Python Turtle Graphics Drawing - Lego® Logo

Youtube

Draw Lego® Logo using bézier curve in Python Turtle Graphics.


Source code:
from turtle import *
from math import atan2, degrees

SCL = 15 # scale
D = 0.05 # bezier step

RED ="#E3000B"

BLACK = [
    (-8.021, 5.702), (-6.187, 8.610),  (-0.952, 8.484),
    (0.279, 6.585),  (2.459, 8.425),  (7.088, 8.576),
    (8.547, 5.896),     (11.516, 9.181),
    (16.352, 8.030),
    (17.192, 5.266),
    (18.104, 1.807),
    (15.322, -4.754),
    (13.437, -6.111),
    (10.494, -8.383),
    (6.377, -7.500),
    (5.573, -4.997),
    (2.619, -8.360),
    (-1.321, -7.782),
    (-2.916, -5.956),
    (-5.379, -8.150),
    (-8.781, -7.604),
    (-10.161, -6.119),
    (-11.854, -7.789),
    (-16.040, -8.061),
    (-17.176, -5.390),
    (-18.144, -2.317),
    (-14.153, 6.068),
    (-12.892, 7.018),
    (-11.372, 8.329),
    (-7.892, 8.228),
    (-8.021, 5.702),
]
YELLOW = [
    (-7.607, 7.616),
    (-5.767, 9.203),
    (-1.112, 9.387),
    (0.394, 7.868),
    (2.755, 9.292),
    (6.670, 9.368),
    (8.718, 7.430),
    (13.184, 10.584),
    (17.470, 8.199),
    (18.132, 5.615),
    (18.961, 1.045),
    (16.348, -5.013),
    (14.556, -6.396),
    (11.114, -9.936),
    (6.342, -8.045),
    (5.371, -6.618),
    (2.263, -9.203),
    (-1.329, -8.591),
    (-2.927, -7.285),
    (-6.230, -9.537),
    (-9.681, -7.869),
    (-10.134, -7.409),
    (-12.192, -8.530),
    (-16.480, -9.380),
    (-18.131, -5.737),
    (-19.427, -2.469),
    (-14.982, 7.106),
    (-13.206, 8.014),
    (-11.782, 8.900),
    (-8.795, 9.450),
    (-7.607, 7.616),
]

C_L = [
    (-12.735, -2.699),
    (-11.428, -2.557),
    (-10.127, -2.461),
    (-10.333, -4.061),
    (-10.538, -5.660),
    (-12.689, -6.635),
    (-14.932, -6.004),
    (-17.176, -5.374),
    (-15.823, -1.896),
    (-15.386, -0.627),
    (-14.949, 0.642),
    (-12.849, 5.809),
    (-11.698, 6.372),
    (-10.673, 6.842),
    (-9.093, 6.834),
    (-9.379, 5.246),
    (-9.690, 3.271),
    (-11.630, -0.384),
    (-12.735, -2.699),
]

C_E = [
    (-5.223, 1.899),
    (-3.319, 2.169),
    (-2.318, 1.781),
    (-2.648, 0.598),
    (-2.996, -0.648),
    (-3.911, -1.304),
    (-6.248, -0.863),
    (-6.467, -1.488),
    (-6.696, -2.097),
    (-6.805, -2.749),
    (-4.598, -2.167),
    (-3.148, -2.592),
    (-3.249, -3.834),
    (-3.315, -4.980),
    (-4.218, -6.131),
    (-6.915, -6.223),
    (-9.532, -6.112),
    (-10.326, -4.355),
    (-9.711, -1.796),
    (-9.108, 1.001),
    (-7.509, 5.160),
    (-6.140, 5.942),
    (-4.625, 7.071),
    (-0.984, 7.112),
    (-0.662, 5.564),
    (-0.310, 4.069),
    (-2.093, 3.157),
    (-4.493, 3.451),
    (-4.863, 2.875),
    (-5.079, 2.502),
    (-5.223, 1.899),
]

C_G = [
    (3.061, -1.293),
    (1.210, -1.243),
    (2.186, 0.937),
    (3.125, 1.222),
    (4.408, 1.585),
    (6.328, 1.590),
    (6.227, -0.230),
    (6.080, -2.211),
    (4.455, -6.216),
    (0.646, -6.228),
    (-3.858, -6.117),
    (-2.708, -1.582),
    (-1.630, 1.224),
    (-0.568, 3.971),
    (0.837, 6.845),
    (4.527, 6.677),
    (7.382, 6.609),
    (8.144, 5.045),
    (7.325, 3.207),
    (6.604, 1.604),
    (4.466, 1.743),
    (4.183, 2.622),
    (4.058, 3.261),
    (4.616, 3.739),
    (4.268, 4.007),
    (4.018, 4.182),
    (3.350, 4.249),
    (2.736, 3.494),
    (1.953, 2.357),
    (0.881, -0.580),
    (0.605, -1.886),
    (0.444, -2.657),
    (0.528, -3.687),
    (1.849, -3.125),
    (2.406, -2.906),
    (2.901, -2.001),
    (3.061, -1.293),
]

C_O1 = [
    (14.034, 6.607),
    (16.027, 6.151),
    (17.004, 4.472),
    (15.636, 0.449),
    (14.743, -2.555),
    (13.539, -6.378),
    (9.280, -6.179),
    (5.778, -5.983),
    (6.081, -2.847),
    (7.687, 1.564),
    (9.151, 6.000),
    (11.405, 7.083),
    (14.034, 6.607),
]

C_O2 = [
    (12.981, 4.036),
    (13.429, 3.909),
    (13.236, 2.704),
    (12.385, 0.323),
    (11.415, -2.196),
    (10.989, -3.489),
    (9.986, -3.277),
    (9.205, -3.041),
    (9.986, -0.819),
    (10.704, 0.997),
    (11.357, 2.713),
    (11.846, 4.366),
    (12.981, 4.036),
]


def Bez(a, b, c, d):
    up()
    goto(a)
    down()
    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 += D
    goto(d)




def getpts(AR, i):
    return [
        tuple([c * SCL for c in AR[i * 3 + 0]]),
        tuple([c * SCL for c in AR[i * 3 + 1]]),
        tuple([c * SCL for c in AR[i * 3 + 2]]),
        tuple([c * SCL for c in AR[i * 3 + 3]]),
    ]


def draw(AR, col):
    n = len(AR) // 3
    begin_fill()
    color(col)
    for i in range(n):
        pts = getpts(AR, i)
        Bez(*pts)
    end_fill()

def circ(p,r,c):
    up()
    pt=tuple([c*SCL for c in p])
    rad = r*SCL
    goto(pt)
    seth(0)
    fd(rad)
    lt(90)
    begin_fill()
    color(c)
    circle(rad)
    end_fill()
    lt(90)
    fd(rad)



def Lego(sc):
    global SCL
    SCL = sc
    c1 = (18.2038,7.9373)
    c1r = 0.95

    c2 = (18.2081,7.93707)
    c2r= 0.75
    fh= 0.97765

    draw(YELLOW, "#FFED00")
    draw(BLACK, "black")
    draw(C_L, "white")
    draw(C_E, "white")
    draw(C_G, "white")
    draw(C_O1, "white")
    draw(C_O2, "black")
    circ(c1,c1r,'black')
    circ(c2,c2r,RED)
    color('black')
    lt(90)
    fd(round(fh*0.8*SCL))
    write("R",False,'center',('Arial',round(fh*SCL*0.95),'bold'))
setup(1000,500)
shape('turtle')
D=0.05
tracer(1)
bgcolor(RED)
Lego(24)
hideturtle()
goto(0,0)
done()


Friday, December 2, 2022

Python Turtle Graphics Drawing - Chrome Logo

 Python Turtle Graphics Drawing - Chrome Logo

Youtube


Source code:

import turtle as t
from math import sqrt
t.setup(640,640)
t.bgcolor('white')
t.tracer(1)
R = 310
# equilateral triangle
a = R/2
L = sqrt(R**2-a**2)
colors = ['#FBBF03', '#E4382A', '#269E49']
blu = '#1374E9'
for i in range(3):
    t.color(colors[i])
    t.up()
    t.lt(90)
    t.fd(a)
    t.down()
    t.begin_fill()
    t.rt(90)
    t.fd(L)
    t.rt(60)
    t.circle(-R,120)
    t.rt(120)
    t.fd(L)
    t.circle(a,120)
    t.end_fill()
    t.up()
    t.lt(90)
    t.fd(a)
    t.lt(90)
    t.lt(120)
r = R/2-R/10
t.fd(r)
t.lt(90)
t.down()
t.color(blu)
t.begin_fill()
t.circle(r)
t.end_fill()
t.hideturtle()
t.done()

Python Turtle Graphic Design #12

Python Turtle Graphic Design #12

 Youtube


Source code:

from turtle import *
import colorsys as cs
import time
setup(640,800)
bgcolor('black')
tracer(0,0)
pensize(2)
shape('turtle')
fnt=('Arial',45,'bold')
for n in range(3,21,1):
    clear()
    goto(0,100)
    down()
    color(cs.hsv_to_rgb((n-3)/20,1,1))
    N = n
    A = 360/N
    for i in range(N):
        for j in range(N):
            fd(100-n*3)
            rt(A)
        rt(A)
    up()
    seth(90)
    goto(0,-320)
    color('white')
    write(f'Sides: {n}',False,'center',fnt)
    goto(0,-250)
    update()
    time.sleep(1)
done()

Circle Animation with ImGui

 Circle Animation with ImGui for C++ Youtube: Source code: void CircFunc () {     static int nc = 360 ;     double radius = 300 ;     ...