xxxxxxxxxx
61
const R = 90;
var a; // rotation
var yOffSet = -50;
function setup() {
createCanvas(400, 400);
angleMode(RADIANS);
a = radians(90)
}
t=-3.14
dt=0.05;
function heart () {
// https://mathworld.wolfram.com/HeartCurve.html
tt=-PI;
push();
beginShape();
fill('yellow')
translate(width/2, height/2)
do {
x = (16* sin(tt) * sin(tt) * sin(tt) )
y = -(13* cos(tt) - (5*cos(2*tt)) - (2*cos(3*tt)) - cos(4*tt))
vertex(x,y);
tt+=dt;
} while (tt < PI)
endShape();
}
function draw() {
push();
beginShape();
fill('red')
translate(width/2, height/2)
do {
x = R* ( .72+cos(t))*cos(t)
y = R* ( 1.2+cos(t))*sin(t)
xx = x * cos(a) - ( y * sin(a))
yy = x * sin(a) - ( y * cos(a)) + yOffSet;
vertex(xx, yy);
point(xx,yy);
t+=dt;
} while (t < PI)
endShape();
pop()
heart();
noLoop()
}