Sunday, November 20, 2022

Python Turtle Graphics Drawing - Twitter Logo

 Python Turtle Graphics Drawing - Twitter Logo

Youtube



Soure code:
from turtle import *

setup(720, 640)
BLUE = '#3C96D1'
WHITE = 'white'
bgcolor(WHITE)


def circ(x, y, r, c, sa=0, se=360):
    up()
    goto(x, -y)
    seth(sa)
    fd(r)
    lt(90)
    down()
    color(c)
    begin_fill()
    circle(r, se-sa)
    end_fill()


R1 = 276.38
R2 = 195.40
R3 = 97.12

circ(-86.07, -83.12, R1, BLUE, 210, 385)
circ(-213.20, -46.26, R2, WHITE, 180, 330)

circ(-91.53, 10.89, R3, BLUE, 180, 360)
circ(-165.43, -54.50, R3, WHITE, 200, 360)
circ(-121.10, -57.10, R3, BLUE, 170, 370)
circ(-170.23, -141.70, R3, WHITE, 210, 360)
circ(-118.86, -126.53, R3, BLUE, 135, 360)

circ(74.28, -255.43, R2, BLUE, 210, 330)
circ(158.28, -327.35, R2, WHITE, 210, 330)

circ(11.54, -350.11, R1, WHITE, 210, 330)

circ(131.58, -215.44, R3, BLUE, 180, 360)
circ(123.87, -351.55, R2, WHITE, 210, 330)

circ(92.11, -96.20, R3, BLUE, 0, 220)

hideturtle()
done()

Thursday, November 17, 2022

Python Turtle Graphics Drawing - Android Logo

 Python Turtle Graphics Drawing - Android Logo

Youtube


Source code:

from turtle import *
from math import radians,sin,cos

col='#3ADC87'

def drawantenna(sz):
    color('red')
    up()
    fd(sz*0.8)
    down()
    color(col)
    begin_fill()
    rt(90)
    fd(sz*0.03)
    lt(90)
    fd(sz*0.45)
    circle(sz*0.03,180)
    fd(sz*0.45)
    lt(90)
    fd(sz*0.03)
    end_fill()
    color('red')
    up()
    rt(90)
    fd(sz*0.8)


def draweye(sz):
    color('red')
    up()
    fd(0.65*sz)
    rt(90)
    fd(0.08*sz)
    lt(90)
    down()
    color('white')
    begin_fill()
    circle(0.08*sz)
    end_fill()
    color('red')
    up()
    lt(90)
    fd(0.08*sz)
    lt(90)
    fd(0.65*sz)


def drawlogo(sz):
    up()
    x = cos(radians(6))*sz
    y = sin(radians(6))*sz
    rt(90)
    fd(0.25*sz)
    lt(180)
    fd(y)
    rt(90)
    down()
    begin_fill()
    fd(x)
    lt(96)
    circle(sz,180-12)
    lt(96)
    fd(x)
    end_fill()
    lt(60)
    drawantenna(sz)
    lt(180+60)
    drawantenna(sz)
    rt(30)
    fd(y)
    lt(90+45)
    color('white')
    draweye(sz)
    rt(90)
    draweye(sz)
    color('black')
    rt(45)
    fd(0.5*sz+y)
    fnt = ('Century Gothic', round(sz*0.4),'bold')
    write('android', align='center', font=fnt)

setup(640, 640)
bgcolor('white')
color(col)
drawlogo(250)
hideturtle()
done()

Tuesday, November 15, 2022

Python Turtle Graphics Drawing - Adobe CC Logo

 Python Turtle Graphics Drawing - Adobe CC Logo

Youtube


Source code:

from turtle import *

red='#DA1F26'

setup(640, 640)
bgcolor('black')
color(red)
up()
fd(160)
down()
lt(90)
begin_fill()
circle(118)
end_fill()
lt(90)
up()
fd(22)
down()
rt(90)
begin_fill()
color('white')
circle(118-22)
end_fill()
lt(90)
up()
fd(22)
down()
rt(90)
begin_fill()
color(red)
circle(118-44)
end_fill()
up()
lt(90)
fd(76)
lt(90)
fd(18)
lt(180)
down()
begin_fill()
circle(100)
end_fill()
lt(90)
up()
fd(100)
rt(180-45)
fd(11)
lt(90)
color('white')
down()
begin_fill()
fd(3)
circle(11,180)
fd(62)
lt(90)
fd(22)
lt(90)
fd(59)
end_fill()
up()
lt(90)
fd(11)
lt(135)
fd(102)
lt(90)
fd(18)
lt(180)
fd(74)
down()
begin_fill()
fd(22)
lt(90)
circle(96,-45)
lt(90)
fd(22)
rt(90)
circle(74,45)
end_fill()
up()
lt(90)
fd(74)
lt(90)
fd(102)
lt(90)
fd(18)
fd(56)
fd(22)
lt(90)
down()
begin_fill()
circle(78,-(180+45))
bk(45)
circle(11,-180)
lt(180)
fd(45)
circle(56,180+45+10)
rt(53)
fd(31)
end_fill()
up()
hideturtle()

done()

Python Turtle Graphics Drawing - Golden Snail

 Python Turtle Graphics Drawing - Golden Snail

Youtube


Source code:

import turtle as t
import colorsys as cs
from math import sin, radians
t.setup(640, 640)
t.tracer(250)
t.bgcolor('black')
t.hideturtle()

for i in range(1440,0,-1):
    l = 0.5+sin(radians(i+160))*0.2
    t.color(cs.hls_to_rgb(0.090,l,1))
    t.pensize(1+i/200)
    t.circle(i/10)
    t.lt(1)

t.done()

Monday, November 14, 2022

Python Turtle Graphic Design #11

 Python Turtle Graphic Design #11

Youtube


Source code:

import turtle as t
import colorsys as cs

t.setup(640, 640)
t.tracer(50)
t.pensize(0)
t.bgcolor('black')
t.hideturtle()

for i in range(1440,0,-1):
    t.color(cs.hsv_to_rgb(i/720, 1, 1))
    t.begin_fill()
    t.rt(60)
    for j in range(3):
        t.fd(i/5)
        t.lt(120)
    t.lt(60)
    t.end_fill()
    t.lt(1)

t.done()

Wednesday, November 9, 2022

Python Turtle Graphics Drawing - Ubuntu Logo

 Python Turtle Graphics Drawing - Ubuntu Logo

Youtube


Source code:

from turtle import *
setup(640,640)
bgcolor('black')
col = '#DD4814'
R = 280
r = 38.91*R/100
w = 19.25*R/100
r2 = 13.39*R/100
r3 = 5.02*R/100
h = 3.77*R/100
l = 68.62*R/100
color(col)
up()
fd(R)
lt(90)
down()
begin_fill()
circle(R)
end_fill()
up()
color('white')
lt(90)
fd(R-(r+w))
rt(90)
down()
begin_fill()
circle(r+w)
end_fill()
up()
lt(90)
color(col)
fd(w)
rt(90)
down()
begin_fill()
circle(r)
end_fill()
up()
lt(90)
fd(r)
rt(120)
down()
color('white')
for i in range(3):
    up()
    fd(l+r2+r3)
    lt(90)
    down()
    color(col)
    begin_fill()
    circle(r2+r3)
    end_fill()
    up()
    lt(90)
    fd(r3)
    rt(90)
    color('white')
    down()
    begin_fill()
    circle(r2)
    end_fill()
    up()
    color('white')
    lt(90)
    fd(l+r2)
    rt(90)
    down()
    color(col)
    begin_fill()
    fd(h)
    lt(90)
    fd(r+w)
    lt(90)
    fd(h*2)
    lt(90)
    fd(r+w)
    lt(90)
    fd(h)
    end_fill()
    up()
    lt(30)
done()

Tuesday, November 8, 2022

Python Turtle Graphic Design #10

 Python Turtle Graphic Design #10

Youtube


Source code:

import turtle as t
import colorsys as cs

t.setup(640,640)
t.bgcolor('black')
t.tracer(100)
t.hideturtle()
h = 0
for i in range(360,0,-1):
    t.begin_fill()
    t.color(cs.hls_to_rgb(h,0.5,1))
    h+=1/1.6180
    t.circle(i/2)
    t.end_fill()
    t.lt(137.5)
t.done()

Monday, November 7, 2022

Python Turtle Graphics Drawing - Sierpiński Triangle

 Python Turtle Graphics Drawing - Sierpiński Triangle


Youtube





Source code:
import turtle as t
import colorsys as cs
from math import sqrt

t.setup(640, 640)
t.bgcolor('black')
t.tracer(10)
t.pensize(2)
R = 500

def tri(r,l):
    if l == 0:
        p=t.pos()
        d = sqrt(p[0]**2+p[1]**2)
        t.color(cs.hls_to_rgb(d/300,0.5,1))
        t.down()
        for i in range(3):
            t.fd(r)
            t.lt(120)
        t.up()
    else:
        t.fd(r/2)
        tri(r/2,l-1)
        t.lt(120)
        tri(r/2,l-1)
        t.fd(r/2)
        t.rt(120)
        tri(r/2,l-1)
        t.rt(120)
        t.fd(r/2)
        t.lt(120)

t.hideturtle()
y = sqrt(R**2-(R/2)**2)
t.up()
t.goto(-R/2,-y/2)
tri(R,7)

t.done()

Friday, November 4, 2022

Python Turtle Graphics Drawing - Fractal Tree

 Python Turtle Graphics Drawing - Fractal Tree

Youtube



Source code:

import turtle as t
import colorsys as cs

t.setup(640,640)
t.bgcolor('black')
t.pencolor('white')
t.tracer(50)

t.up()
t.rt(90)
t.fd(150)
t.lt(180)
t.down()

def tree(a1,a2,d):
    if d<0:
        return
    t.color(cs.hls_to_rgb(d/11,0.5,1))
    t.pensize(d+1)
    t.fd(d*6)
    p = t.pos()
    h = t.heading()
    t.lt(a1)
    tree(a1,a2,d-1)
    t.up()
    t.goto(p)
    t.seth(h)
    t.rt(a2)
    t.down()
    tree(a1,a2,d-1)

tree(25,25,11)
t.done()

Thursday, November 3, 2022

Python Turtle Graphic Design #9

 Python Turtle Graphic Design #9

Youtube



Source code:

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

t.setup(640,640)
t.bgcolor('black')
t.tracer(5)
t.pensize(1)
t.up()
k=6
r=1
i=0
while True:
    t.color(cs.hls_to_rgb(r/25,0.5,1))
    R = k*r
    a =radians(i)
    x = R*cos(a)+r*cos(R*a)
    y = R*sin(a)-r*sin(R*a)
    t.goto(x,y)
    t.down()
    i+=1
    r+=0.005
    if r>50:
        break
t.done()

Tuesday, November 1, 2022

Python Turtle Graphics Drawing - Golden Ration

 Golden Ration - Python Turtle Graphics

Youtube





Source code:
import turtle as t
t.setup(640,640)
t.bgcolor('white')
G = 1.618
R = 1
t.speed(10)
t.up()
t.fd(115)
t.rt(90)
t.fd(60)
t.rt(90)
t.down()
for i in range(13):
    t.pensize(1)
    t.color('gray')
    for j in range(4):
        t.fd(R)
        t.lt(90)
    t.pensize(2)
    t.color('black')
    t.circle(R,90)
    R *= G
t.done()

Circle Animation with ImGui

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