Interactive Art [Week 4] - Math Flower

Week 4 - Nature patterns 


For this project I took inspiration from the mathematical distribution of certain flowers and look up to a formula that changes the petals pattern according to a variable, in the first example the variable changes according to the value given from the slider and in the second example the value is a random number between the value of the slider as the minimum and 15 as maximum

File: https://drive.google.com/file/d/12Kg3kC0S6QafEL4nRxh6j-fDJATS661D/view?usp=sharing

Code

import controlP5.*;
ControlP5 cp5;

float slider;
float k;

void setup(){
  size(500,500);
 
  cp5 = new ControlP5(this);
  cp5.addSlider("slider")
  .setPosition(0,0)
  .setSize(400,20)
  .setRange(0.0,15.0);
}

void draw (){
  background(50);
 
pushMatrix();
  translate(width/2, height /2);
 
  beginShape();
  stroke(255);
  noFill();
  strokeWeight(1);
 
  for (int i = 0; i < 100; i++) {
     k = random(slider,15);
  }

  for(float a=0; a<TWO_PI; a+=0.02){
    float r = 200*cos(k*a);
    float x = r*cos(a);
    float y = r*sin(a);
    vertex(x,y);
  }
 
  endShape(CLOSE);
popMatrix();
}

Comentarios

Entradas más populares de este blog

Interactive Art [Week 5] - Arrays

Interactive Art [Week 8] - Interactive Button

Interactive Art [Week 11] - Installation