• fullscreen
  • physics_ring_painter_mini.pde
  • import traer.physics.*;
    
    ParticleSystem PS = new ParticleSystem(0.0, 0.5);
    int pcount = 400;
    int ring_radius = 135;
    Particle[] Ring = new Particle[pcount];
    Spring[] Innersprings = new Spring[pcount*2]; // two springs per particle
    Spring[] Rim = new Spring[pcount];
    float spokeStrength = 0.008;
    float spokeDamping = 0.0;
    float rimDamping = 0.01;
    float rimStrength = 1.0;
    float innerspring_length = ring_radius*2.5;
    float z=0; // increment this as the shape draws
    int h=0; // random hue value
    
    void setup(){
      size(600,600);
      background(255);
      smooth();
      colorMode(HSB,255);
      h = int(random(255));
      buildParticles(PS);
    }
    
    void draw(){
      PS.tick();
      translate(height/2,width/2);
      strokeWeight(2);
      stroke((h+(z*0.03))%255,255-(z*0.1),z*0.15,40);
      fill(255);
      // draw the ring
      beginShape();
      for (int p=0; p<pcount; p++){
        vertex(Ring[p].position().x(),Ring[p].position().y());
      }
      endShape(CLOSE);
      // now shorten the springs
      for (int s=0; s<pcount; s++){
        int spr = int(random(pcount)); // note we only shorten half the springs (the first half)
        Innersprings[spr].setRestLength(Innersprings[spr].restLength() - random(0,1));
     }
      z++;
    }
    
    
    void buildParticles(ParticleSystem P){
      for (float i=0; i<pcount; i++){ // makes the particles
        Ring[int(i)] = P.makeParticle(1.0,sin(TWO_PI*(i/pcount))*ring_radius,cos(TWO_PI*(i/pcount))*ring_radius,0);
      }
      float segmentlength = (TWO_PI*ring_radius)/float(pcount); // segment length
      
      for (int i=0; i<pcount; i++){ 
        Innersprings[i] =  P.makeSpring(Ring[i], Ring[int(random(pcount))],spokeStrength, spokeDamping, innerspring_length); // 2 random springs
        Innersprings[i+pcount] =  P.makeSpring(Ring[i], Ring[(i+int(random(pcount)))%pcount], spokeStrength, spokeDamping, innerspring_length); // between each point and 2 others
        if (i < pcount-1) {
          Rim[i] = P.makeSpring(Ring[i],Ring[i+1],rimStrength, rimDamping,segmentlength);
        }
        else { // join the last rim particle back to the first
          Rim[i] = P.makeSpring(Ring[i],Ring[0],rimStrength, rimDamping, segmentlength);
        }
      }
    }
    
    void keyPressed(){
        buildParticles(PS);
        h = int(random(255));
        background(255);
        z = 0;
    }
    
    
    
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    mitchell whitelaw

    scrunch / flower generator

    Add to Faves Me Likey@! 236
    You must login/register to add this sketch to your favorites.

    A simple painting machine using physical simulation (via traer physics). A loop of "string" is scrunched to create intricate flower-like forms. Hit any key to regenerate.

    kath
    24 Jun 2009
    so beautiful! great job!!
    Jean-no
    24 Jun 2009
    Very nice effect
    Matt Richard plus+
    29 Jun 2009
    I like how your choice of colors creates an effect of light radiating from the center. This really reminds my of Jared Tarbell's "Happy Place", which consider to be one of the best examples of Generative Art.

    Happy Place:
    http://complexification.net/gallery/machines/happyPlace/index.php
    Thanks all, Matt it's an honour to be compared to Tarbell's work :)
    jordan bilich
    5 Jul 2009
    Wow, keep up the good work!
    lovely ^^
    Rafael Cosman
    19 Aug 2009
    Nice effect. Is there a way the user could control it?
    Rafael - sure, you could use the mouse position to vary the rate at which the springs shrink - eg springs attached to particles close to the mouse could shrink faster. I might just try it...
    Bryan Teoh
    28 Dec 2009
    wow...this is really beautiful!
    arquine wong
    7 Jan 2010
    so beautiful artwork!
    Beautiful!
    bejoscha
    1 Apr 2010
    Wow! Great. There is so much fun-potential in Jeff traers particle library. I've been toying with his springs myself, but your example is simply beautiful.
    Wiley Wiggins
    13 May 2010
    This is a really elegant, lovely sketch. I'd love to ask you a couple of questions about it some time if you are available.
    Wiley thanks, happy to discuss, fire away (here or wherever)...
    Wiley Wiggins
    17 May 2010
    I was wondering if you would be interested in being contracted to modify this sketch a little for a motion graphics project.

    How hard do you think it would be to modify the sketch so that the lines conform to the edges of a predefined shape once they shrink?

    my email is weevil@wileywiggins.com
    Wiley Wiggins
    17 May 2010
    I was wondering if you would be interested in being contracted to modify this sketch a little for a motion graphics project.

    How hard do you think it would be to modify the sketch so that the lines conform to the edges of a predefined shape once they shrink?

    my email is weevil@wileywiggins.com
    Wiley Wiggins
    17 May 2010
    stupid submit button :(
    ok, I take it as a feedback :)
    peoplepeople
    10 Oct 2012
    Mitchell Whitelaw is there a way I can contact you I really need your help with something
    Keith Rowell
    13 Jan 2013
    My attempts at tweaking have errors upon uploading to OP. "can't find physics". May I ask where the physics file is supposed to be in the applet dir?
    Maf'j Alvarez
    21 Dec 2013
    It's really beautiful - stunning.
    You need to login/register to comment.