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()

No comments:

Post a Comment

Circle Animation with ImGui

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