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

Python Turtle Graphics Drawing - Gigabyte

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