Monday, October 31, 2022

Python Turtle Graphic Design #8

 Python Turtle Graphic Design #8

Youtube



Source code:

import turtle as t
import colorsys as cs
t.setup(640,640)
t.bgcolor('black')
t.tracer(100)
t.hideturtle()
N = 5
A = 360/N
t.lt(45)
for i in range(360,0,-1):
    h = (i % N)/N
    l = i/720
    s = 0.5+ i / 720
    t.color(cs.hls_to_rgb(h,l,s))
    t.begin_fill()
    t.circle(i/2,90)
    t.lt(90)
    t.circle(i/2,90)
    t.end_fill()
    t.lt(90+A-0.1)
t.done()

Friday, October 28, 2022

Python Turtle Graphic Design #7

 Python Turtle Graphic Design #7

Youtube




Source code:

import turtle as t
import colorsys as cs

t.setup(640,640)
t.bgcolor('black')
t.tracer(10)
t.pensize(3)
N = 5
S = 2
A = S*360/N
for i in range(360):
    t.color(cs.hls_to_rgb((i%N)/N,0.5,1))
    t.fd(i)
    t.lt(A)

t.done()

Wednesday, October 26, 2022

Python Turtle Graphic Design #6

 Python Turtle Graphic Design #6

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(300,0)
t.hideturtle()

N = 18 # number of petals
R = 250 # radius
STEP = 3
A = 360/N
A2 = A/2
B = 180-(90+A2)
D = 90-B

t.lt(90)
for j in range(R,0,-STEP):
    XR = cos(radians(A2))*j
    YR = sin(radians(A2))*j
    for i in range(N):
        h = i/N
        l = j/(R*1.75)
        s = 1
        t.color(cs.hls_to_rgb(h,l,s))
        t.begin_fill()
        t.rt(A2)
        t.fd(XR)
        t.circle(YR,180+D*2)
        t.fd(XR)
        t.end_fill()
        t.rt(180-A2)
t.done()

Python Turtle Graphic Design #5

 Python Turtle Graphic Design #5

Youtube


Source code:

import turtle as t
import colorsys as cs
t.setup(640,640)
t.bgcolor('black')
t.tracer(100)
t.hideturtle()
for i in range(600,0,-1):
    t.color(cs.hls_to_rgb((600-i)/1200,0.5-(600-i)/2400,i/600))
    t.fd(i/2)
    t.lt(120)
    t.begin_fill()
    for j in range(6):
        t.fd(i/2)
        t.lt(60)
    t.end_fill()
    t.lt(60)
    t.fd(i/2)
    t.rt(179)
t.done()

Tuesday, October 25, 2022

Python Turtle Graphic Design #4

Python Turtle Graphic Design #4


 Youtube



Source code:

import turtle as t
import colorsys as cs
t.setup(640,640)
t.bgcolor('black')
t.tracer(100)
t.pensize(1)
t.hideturtle()
cols = ['#f00','#0f0','#f70','#00f']
for i in range(360):
    t.pencolor(cols[i % 4])
    t.fillcolor(cols[i % 4])
    t.begin_fill()
    t.circle(i/3,180)
    t.lt(90)
    t.fd(i/3)
    t.rt(179)
    t.end_fill()

t.done()

Python Turtle Graphic Design #3

Python Turtle Graphic Design #3


Youtube



 Source code:

import turtle as t
import colorsys as cs

t.setup(640,640)
t.tracer(100)
t.bgcolor('black')
t.pensize(2)

for i in range(360):
    t.pencolor(cs.hls_to_rgb(i/9,1-i/360,0))
    t.circle(i,60)
    t.rt(40)
    t.pencolor(cs.hls_to_rgb(i/9,0.5,1))
    t.fd(i/4)
    t.rt(180)
    t.fd(i)

t.done()

Monday, October 24, 2022

Python Turtle Graphics Design #2

 Python Turtle Graphics Design #2


Youtube







Source code:

import turtle as t
import colorsys as cs

t.setup(500,500)
t.bgcolor('black')
t.tracer(50)
for i in range(360):
    c = cs.hls_to_rgb(i/180,0.5,i/360)
    t.pencolor(c)
    t.fd(i/2)
    t.rt(35)
    t.circle(i/2,45)
    t.lt(95)
t.hideturtle()
t.done()


Thursday, October 20, 2022

ASMR Programming - Python Turtle 02

 Tinkering Turtle Graphics

Creating Polygon and Stars




Code:
import turtle as t
from math import sin,cos,radians

t.setup(800,800)
t.bgcolor('black')


def ngon(n,r,sa):
    '''
    POLYGON
    '''
    ang = 360/n
    p = t.pos()
    t.up()
    for i in range(n+1):
        a=radians(i*ang+sa)
        x=p[0]+cos(a)*r
        y=p[1]+sin(a)*r
        t.goto(x,y)
        t.down()
    t.up()
    t.goto(p)

def star(n,r1,r2,sa):
    '''
    STAR
    '''
    ang = 360/(n*2)
    p=t.pos()
    t.up()
    for i in range(n*2+1):
        a=radians(i*ang+sa)
        x=p[0]+cos(a)*(r2 if i%2==0 else r1)
        y=p[0]+sin(a)*(r2 if i%2==0 else r1)
        t.goto(x,y)
        t.down()
    t.up()
    t.goto(p)

def starx(n,r,sa):
    '''
    STAR CROSSING
    '''
    ang=720/n
    p=t.pos()
    t.up()
    for i in range(n+1):
        a=radians(i*ang+sa)
        x=p[0]+cos(a)*r
        y=p[0]+sin(a)*r
        t.goto(x,y)
        t.down()
    t.up()
    t.goto(p)


t.pencolor('white')
ngon(3,150,90)
t.pencolor('white')
star(10,100,200,90)
t.pencolor('white')
starx(7,50,90) #--- needs more work..


t.done()


Keyboard I use:


Monday, October 17, 2022

Python Turtle Graphics Design #1

Python Turtle Graphics Design #1

Youtube

code:

import turtle as t
import colorsys as cs

def donut(r1,r2,c):
    for i in range(360//5):
        t.pencolor(c)
        t.fd(r1)
        t.down()
        t.circle(r2,360)
        t.up()
        t.backward(r1)
        t.lt(5)


t.setup(500,500)
t.tracer(100,0)
t.tracer(1)
t.speed(0)
t.bgcolor('black')
t.up()
for i in range(10):
    donut(200-i*20,50-i*5+1,cs.hls_to_rgb(i/25,0.5,1))

t.done()



ASMR Programming - Python Turtle

 ASMR Programming - Python Turtle - Tinkering - No Talking

Code for this video:

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

ANG = 60
R = 200
t.speed(0)
t.tracer(1000,0)
t.bgcolor('black')

for i in range(1000):
    t.pencolor(cs.hls_to_rgb(i/1000, i/1000, 0.5+i/2000))
    a = sin(radians(ANG/2))*R
    b = cos(radians(ANG/2))*R
    t.rt(ANG/2)
    t.fd(b)
    xang = 90-(180-(90+ANG/2))
    cang = 180 + xang*2

    t.circle(a,cang)
    t.fd(b)
    t.rt(180-ANG/2)
    R-=0.2

t.done()

Preview



Python Turtle Graphics Drawing - Gigabyte

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