Python Turtle Graphics Drawing - Heart
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