Javier Amador: Cardioide
De Casiopea
Título | Javier Amador: Cardioide |
---|---|
Del Curso | Imagen Escrita 2017 |
Nº | 4 |
Alumno(s) | Javier Amador |
float inc; int sides = 2048; void setup() { size(500, 500); inc = TWO_PI / float(sides); fill(#FDF5E6); } void draw() { float a = 0; float b = 0; background(#458B74); translate(width/2, height/2); beginShape(); for (float t = 0; t < TWO_PI; t += inc) { a = mouseX/2; b= map(mouseY, 0, 500, 0, 3); //Cardioide: //r=2a(1+cos(t)) float r=2*a*(b+cos(t)); float x = cos(t) * r; float y = sin(t) * r; vertex(x, y); } endShape(); println(a); println(b); }
<processingjs> float inc; // incremento int sides = 2048; // lados
void setup() {
size(500, 500); inc = TWO_PI / float(sides); fill(#FDF5E6);
}
void draw() {
float a = 0; float b = 0; background(#458B74); translate(width/2, height/2);
beginShape();
for (float t = 0; t < TWO_PI; t += inc) {
a = mouseX/2; b= map(mouseY, 0, 500, 0, 3); //Cardioide: //r=2a(1+cos(t)) float r=2*a*(b+cos(t));
float x = cos(t) * r; float y = sin(t) * r;
vertex(x, y); } endShape(); println(a); println(b);
}
</processingjs>