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

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 ;     ...