We code for France (Remembering 11/13/2015)

Hello all. I am sorry to those who are so picky that I am opening up a non programming based topic. I apologize. I believe that we here at the Processing Forums can also sympathize with those in France, who have suffered through this tragic happening. Here at Processing I would like all to post here on this discussion:

int width = 25;
int height = 50;

int x1 = 10;
int x2 = 10+width;
int x3 = 10+(width*2);

int y = 30;

void draw(){
stroke(0);
fill(0,0,255);
rect(x1,y,width,height);
fill(255);
rect(x2,y,width,height);
fill(255,0,0);
rect(x3,y,width,height);
}

It is a french flag and you can copy and paste the code to show your support. Thank you all, and please add your hearts to those aiding those in France.

Comments

  • I code for France!

    PVector p0 = new PVector();
    PVector p1 = new PVector();
    
    public void setup() {
      size(320, 240);
      // Flag
      background(255, 0, 0);
      fill(255);
      rect(0, 0, 0.667 * width, height);
      fill(0, 0, 255);
      rect(0, 0, 0.333 * width, height);
      drawHeart(2.7);
    }
    
    void drawHeart(float m) {
      float t, tmin = -PI, tmax = PI, tdif = 0.22;
      t = tmin;
      pushMatrix();
      translate(width/2, height/2.35);
      stroke(255, 0, 0, 64);
      strokeWeight(16);
      calcPos(p0, t, m);
      while (t < tmax) {
        calcPos(p1, t, m);
        line(p0.x, p0.y, p1.x, p1.y);
        p0.set(p1);
        t += tdif;
      }
      popMatrix();
    }
    
    public void calcPos(PVector v, float t, float size) {
      v.x = 16 * pow( sin(t), 3);
      v.y = -(13*cos(t) - 5 * cos(2*t) -2*cos(3*t) - cos(4*t));
      v.mult(size);
    }
    
  • Peace..............

    // make a moving spiral of particles. 
    
    Particle[] pars = new Particle[360];
    
    final int densityAttractors = 1;  // 1 close to, 9 far from each other 
    final int steepnesSpiral    = 7;  // 4 is good, 14 would be very dense spiral
    
    color[] franceColors = {
      color(255, 0, 0), 
      color(2, 0, 255), 
      color(255)
    };
    
    
    int franceColorsIndex = 0; 
    
    void setup() {
    
      size(800, 800);
      stroke(255);
      strokeWeight(12);
    
      int j=0; // j is needed when densityAttractors!=1 
    
      for (int i=pars.length; i>0; i--) { 
        if (i%densityAttractors == 0) {
          pars[j] = new Particle( (i*steepnesSpiral)%360, i );
          j++;
        } // if
      } // for
      println ("End of setup().");
    } // func
    
    void draw() {
      if (mousePressed) {
        background(0);
      }
      for (int i=0; i<pars.length; i++) {
        // if (pars[i]!=null)
        pars[i].draw();
      } // for
      if (frameCount%48==0)
        franceColorsIndex++;
      if (franceColorsIndex>2)
        franceColorsIndex=0;
    } // func 
    
    // ========================================
    
    class Particle {
    
      float r;      // radius  // changing 
      float angle;  // angle   // const 
    
      // constr 
      Particle(float angle_, float r_) {
        angle = angle_;
        r     = r_;
      }// constr 
    
      void draw() {
    
        // draw and change here 
    
        // paint it 
        if (r>=0) {
          point(width/2+r*cos(radians(angle)), height/2+r*sin(radians(angle)));
        }
    
        stroke(franceColors [franceColorsIndex] ); // red 
        point(width/2+r*cos(radians(angle)), height/2+r*sin(radians(angle)));
        stroke(255); // white
    
    
        // change it 
        r++; // fly outwards
        if (r > 360) {  
          r=0;
        } // if
      } // method
    } // class 
    
    // ==================================
    
  • Thank you all. Please continue posting. All of Processing. Code for France

  • Peace

    void setup() {
      size(400, 400);
      background(0);
    }
    
    void draw() {
      background(0);
      translate(width/2, height/2);
      float f = frameCount/100.00;
      float s =  abs(cos(sin(f*3)+f*3));
      scale(s*0.8);
      peace();
    }
    
    void peace() {
      pushMatrix();
      translate(-width/2, -height/2);
      noStroke();
      fill(#0055A4);
      ellipse(width/2, height/2, 380, 380);
      fill(#ffffff);
      rect(180, 10, 40, 380);
      pushMatrix();
      translate(192, 210);
      rotate(radians(-50));
      rect(0, 0, 40, 200);
      popMatrix();
    
      pushMatrix();
      translate(196, 169);
      rotate(radians(50)); 
      rect(0, 0, 40, 200);
      popMatrix();
    
      noFill();
      stroke(#EF4135);
      strokeWeight(30);
      ellipse(width/2, height/2, 380, 380);
      popMatrix();
    }
    
  • Thank you for the suggestion Kevin Workman!

  • size(780, 520);
    PImage flag = createImage(3, 1, RGB);
    noSmooth();
    flag.loadPixels();
    flag.pixels[0] = color(0,85,164);
    flag.pixels[1] = color(255,255,255);
    flag.pixels[2] = color(239,65,53);
    image(flag, 0, 0, width, height);
    
  • One more:

    size(780, 520);
    background(255);
    stroke(0,85,164);
    strokeWeight((width/3)*2);
    line(0,0,0,height);
    stroke(239,65,53);
    line(width,0,width,height);
    
  • shortest way i found to solve this code-golf-thing in processing:

    size(78,52);stroke(255);strokeWeight(26);background(#EF4135);fill(#0055A4);rect(-13,-13,52,78);

    95 Bytes.

  • edited November 2015

    Nice solution. Inspired by you, a tiny shorter with different colors (so breaking the rules from the page...).

    size(78,52);stroke(-1);strokeWeight(26);background(-65536);fill(#0055A4);rect(-13,-13,52,78);

  • @benja very clever : ) ^:)^ :-bd

  • edited November 2015

    With scale() instead of strokeWeight(), now 89 Bytes:

    size(78,52);scale(26,52);stroke(255);background(#EF4135);fill(#0055A4);rect(-2,-1,3.5,3);

    @clankill3er: I really like the idea with the negative color-values!

  • How does those negative values work?

  • Look at their bit representation. A minus sign is usually represented with a 1 at the beginning of the number, but only where the system expects it. Say you have an 8 bit number (a byte). Then you could have values between 0 (0000 0000) and 255 (1111 1111). But if you're on a system which handles minus signs your range is from -127 to 127 because the first bit is the minus sign. Colours don't use a minus sign so it looks for values between 0 and 255 so when you enter a negative number it thinks that bit is representing a number, not a sign.

  • The current Processing entry takes 100 bytes, so you should submit yours!

  • Ok i did, using -1 as white makes this even one byte smaller.

  • edited November 2015

    as we are 25/11:: (not time enough to index z var to frequency:: todo!!!)

                 import processing.opengl.*;
        import ddf.minim.*;
        import ddf.minim.signals.*;
    
        /////////////////////////////////////////
    
        float espaceX = 1.25;  
        int largeur;             
    
        //float periode; 
        //float diffX;  
        ArrayList<Sinuso> tableauSin;
        Sinuso sinus;
        color couleur;
        Minim minim;
        AudioPlayer player;
    
        ////////////////////////////////
    
        void setup() {
    
          size(1024, 768, OPENGL);
           background(0);
          largeur = width+24;
          tableauSin = new ArrayList();
          for(int i = 0; i<15; i++){
          float periode = random(100,500);
        float amplitude = random(100,height/2);
        float diffX = (TWO_PI / periode) * espaceX;
        float angl = random(1500,3000);
    
        int zard = int( random(4));
        if(zard==0){
        couleur= color(2,24,242);
        }else if(zard==1){
          couleur = color(255,0,0);
        }else if( zard ==2){
          couleur = color(255,255,255);
        }else{
          couleur = color(0,0,0);
        }
    
        sinus = new Sinuso(angl, amplitude,periode, diffX,couleur);
        tableauSin.add(sinus);
    
    
          }
    
           minim = new Minim(this);
           player = minim.loadFile("http://www.akenaton-docks.fr/DOCKS-datas_f/collect_f/auteurs_f/C_f/CASTELLIN_f/anim_f/liensZip/aylermarseil.mp3",1024);
           player.loop();
           player.play();
           player.setGain(10.0);
    
        };
    
        void draw() {
          background(0);
          frameRate(60);
    
          for (int i= 0; i<tableauSin.size();i++){
             sinus = (Sinuso) tableauSin.get(i);
    
        sinus.evalueCourbe();
          }
          fill(255);
          textSize(14);
        text("Albert Ayler, 13/07/1936 - 25/11/1970", 50,700);
        };
    
        void stop() {
          //on ferme l'audio quand tout s'arrete
          player.close();//le player est tué
          minim.stop();//minim est tué
    
          super.stop();//on arrete la superClasse audio Minim
        }
    

    ////////////////////////////////////////////

            class Sinuso {
          float angle;
          float periode;
          float amplitude;
          float resetAmpl;
          float diffX;
          float[] tableauY; 
          color coul;
          float initDiffx;
         // float rot = 0.00000000002;
    
        Sinuso(float thet, float ampl,float per, float dxx, color c){
         angle = thet;
        amplitude = ampl;
        periode = per;
        diffX = dxx;
        initDiffx = dxx;
        resetAmpl = amplitude;
        coul = c;
    
        }
    
        void evalueCourbe() {
    
           tableauY = new float[int(largeur/espaceX)];
         angle += random(-0.04,0.4);
         //println("angle========" +angle);
         if (frameCount%50 == 0){
         float varAmp = random(15,200);
         amplitude = amplitude + varAmp;
         }
    
         println(amplitude);
        //amplitude = random(25,100);
    
          for (int i = 0; i <tableauY.length; i++) {
            tableauY[i] = sin(angle)*amplitude;
            angle+=diffX;
            if (angle>4000){
              angle = random(1000,3000);
              diffX= initDiffx;
              amplitude = resetAmpl;
            }
          }
         traceCourbe();
        }
    
        void traceCourbe() {
          pushMatrix();
          translate(0, 0,random(-3000,-1000));
          noStroke();
          smooth();
    
          fill(coul);
    
          noStroke();
    
          for (int x = 0; x < tableauY.length; x++) {
    
            ellipse(x*espaceX, height/2+tableauY[x], 20, 20);
    
          }
          popMatrix();
        }
    
        }
    
Sign In or Register to comment.