Unluckily I was too lazy to do it right. Of course someone will take my crappy code and uncrap it. Have fun!
int width=1200; int height=800;
int saize = 800;
int depth = 5
float rotx, roty;
void setup() {
size(width,height);
background(0);
frameRate(2);
}
void draw() {
drawHeart(width/2, 0, saize/2, depth, false, false);
}
void drawHeart(int x, int y, int s, int depth, boolean down, boolean right) {
if (depth <= 0) {
return;
}
int r = (int)(s*0.25);
int dy = (int)(s/2);
int dx = s/2;
Point p1 = new Point(x-dx, y + dy);
Point p2 = new Point(x+dx, y + dy);
Point p3 = new Point(x, y);
//myline(p1, p2, 128);
myline(p2, p3, 128);
myline(p3, p1, 128);
float angle = PI/6;
int xr = (int)(cos(angle)*r);
int yr = (int)(sin(angle)*r);
noFill();
int a = 20;
int b = 9;
arc(x + dx - xr, y + dy + yr, 2*r, 2*r, -PI/6, PI/2);
arc(x + dx - xr, y + dy + yr, a*(dx-xr)/b, 2*r, PI/2, PI-PI/7);
arc(x - dx + xr, y + dy + yr, 2*r, 2*r, PI/2, PI + PI/6);
arc(x - dx + xr, y + dy + yr, a*(dx-xr)/b, 2*r, PI/7, PI/2);
//arc(x + r/8, y + h, r/4, r/4, 0, PI);
drawHeart(x, y + dy + yr + r/2, 2*s/5, depth-1, true, false);
if (down) {
drawHeart(x + 2*(dx-xr), y + 3*dy/5, s/5, depth -1, false, true);
drawHeart(x - 2*(dx-xr), y + 3*dy/5, s/5, depth -1, false, false);
}
else
{
if (right) {
drawHeart(x + (dx +r/2), y, s/2, depth -1, false, true);
drawHeart(x - (dx +r/2), y, s/2, depth -1, false, false);
}
else //if left
{
drawHeart(x + (dx +r/2), y, s/2, depth -1, false, true);
drawHeart(x - (dx +r/2), y, s/2, depth -1, false, false);
}
}
}
void myline(Point p1, Point p2, int colour) {
line(p1.x, p1.y, p2.x, p2.y);
stroke(colour);
}
1 Kommentar:
schön!
Kommentar veröffentlichen