Loading...
Logo
Processing Forum
Hi!
I am a student who has an assignment I need some help with. The task is to make data into coding, and I am not the best at that. 

Every dot describes my instagram photoes. the size it the amount of likes, and the color is telling what kind of picture it is. This is what I have so far. 

 
 void setup(){
  size(1000,420);
  smooth();
  background(0);
  noStroke();

}

 void draw() {
   
int [] hours = {10,18,11,12,20,18,17,21,19,22,19,23,17,14,16,11,18,21,13,20,11,20,1,13,11,21,23,21,19,18,14,17,14,15,20,17,21,13,14,18,9,22,17,6,19,23,16,13,15,0,17,12,14,15,18};
int [] days = {4,4,5,6,6,0,1,2,3,4,5,5,6,0,1,2,3,4,5,5,6,0,1,1,2,3,3,4,5,6,0,1,2,3,3,4,5,6,0,1,2,4,5,6,0,1,2,3,3,4,5,0,0,1,2};
int [] likes = {47,44,18,14,14,19,13,7,21,7,13,37,22,32,24,13,25,15,16,8,19,16,25,7,12,6,13,11,7,15,20,20,12,17,15,36,22,23,21,18,6,17,16,20,34,12,12,36,44,14,15,17,23,13,16};
color [] tagg = {
                  color(255,0,0),
                  color(255,0,0),
                  color(255,0,0),
                  color(255,100,0),
                  color(0,0,255),
                  color(255,0,255),
                  color(0,255,255),
                  color(255,0,255),
                  color(0,255,0),
                  color(0,255,255),
                  color(255,0,255),
                  color(0,255,0),
                  color(200,250,0),
                  color(0,255,0),
                  color(0,0,255),
                  color(255,0,255),
                  color(0,255,255),
                  color(255,0,255),
                  color(255,100,0),
                  color(255,100,0),
                  color(0,255,255),
                  color(255,0,0),
                  color(255,100,0),
                  color(255,0,255),
                  color(0,0,255),//
                  color(255,0,255),
                  color(255,100,0),
                  color(255,100,0),
                  color(0,0,255),
                  color(0,255,0),
                  color(0,255,0),
                  color(100,100,100),
                  color(255,0,0),
                  color(100,100,100),
                  color(255,100,0),
                  color(0,0,255),
                  color(255,0,255),
                  color(0,0,0),
                  color(0,0,255),
                  color(255,0,0),
                  color(200,255,0),
                  color(255,0,255),
                  color(0,255,255),
                  color(255,200,0),
                  color(255,0,255),
                  color(0,0,255),
                  color(0,255,0),
                  color(0,0,255),
                  color(255,0,0),
                  color(255,100,0),
                  color(0,0,255),
                  color(255,100,0),
                  color(0,255,255),
                  color(0,0,255),
                  color(0,0,255), 
        
      };    
     
  for(int i = 0; i < days.length; i++) {    
  fill (tagg[i]);
  ellipse (hours[i]*40, days[i]*70, likes[i]*2, likes[i]*2); // (x,y, s, s);
  }
  
}


The dots have to stay where they are, but I want to give them a growing effect. I found this code online. And is kind of what I would like. 



float[] x, y, sz;
int [] cursz;
 
void setup()
{
  size(400, 400);
  smooth();
  background(0);
  colorMode(HSB, 360, 100, 100);
  noFill();
  strokeWeight(1);
  frameRate(45);
 
  int n = 7;
  x = new float[n];
  y = new float[n];
  sz = new float[n];
  cursz = new int[n];
 
  for (int i = 0; i < x.length; i++) {
    initShape(i);
  }
}
 
void draw()
{
  for (int i = 0; i < x.length; i++) {
    drawRing(frameCount, x[i], y[i], cursz[i]);
    cursz[i]++;
    if (cursz[i] > sz[i]) {
      initShape(i);
    }
  }
  noStroke();
  fill(0, 0, 0, 5);
  rect(0, 0, width, height);
}
 
void initShape(int i)
{
  x[i]  = random(width);
  y[i] = random(height);
  sz[i] = 10  + random((width - 30)/ 3); 
  cursz[i] = (int) sz[i] / 2;
}
 
void drawRing(int count, float x, float y, int sz)
{
  int hue = (count % 360 + (int) (x + y) ) % 360;
  stroke(hue, 85, 95);
  ellipse(x, y, sz, sz);
}

Can you pleace try to help me combining the two? 

Replies(3)

Copy code
  1. int [] hours = {
  2.   10, 18, 11, 12, 20, 18, 17, 21, 19, 22, 19, 23, 17, 14, 16, 11, 18, 21, 13, 20, 11, 20, 1, 13, 11, 21, 23, 21, 19, 18, 14, 17, 14, 15, 20, 17, 21, 13, 14, 18, 9, 22, 17, 6, 19, 23, 16, 13, 15, 0, 17, 12, 14, 15, 18
  3. };
  4. int [] days = {
  5.   4, 4, 5, 6, 6, 0, 1, 2, 3, 4, 5, 5, 6, 0, 1, 2, 3, 4, 5, 5, 6, 0, 1, 1, 2, 3, 3, 4, 5, 6, 0, 1, 2, 3, 3, 4, 5, 6, 0, 1, 2, 4, 5, 6, 0, 1, 2, 3, 3, 4, 5, 0, 0, 1, 2
  6. };
  7. int [] likes = {
  8.   47, 44, 18, 14, 14, 19, 13, 7, 21, 7, 13, 37, 22, 32, 24, 13, 25, 15, 16, 8, 19, 16, 25, 7, 12, 6, 13, 11, 7, 15, 20, 20, 12, 17, 15, 36, 22, 23, 21, 18, 6, 17, 16, 20, 34, 12, 12, 36, 44, 14, 15, 17, 23, 13, 16
  9. };
  10. color [] tagg = {
  11.   color(255, 0, 0), 
  12.   color(255, 0, 0), 
  13.   color(255, 0, 0), 
  14.   color(255, 100, 0), 
  15.   color(0, 0, 255), 
  16.   color(255, 0, 255), 
  17.   color(0, 255, 255), 
  18.   color(255, 0, 255), 
  19.   color(0, 255, 0), 
  20.   color(0, 255, 255), 
  21.   color(255, 0, 255), 
  22.   color(0, 255, 0), 
  23.   color(200, 250, 0), 
  24.   color(0, 255, 0), 
  25.   color(0, 0, 255), 
  26.   color(255, 0, 255), 
  27.   color(0, 255, 255), 
  28.   color(255, 0, 255), 
  29.   color(255, 100, 0), 
  30.   color(255, 100, 0), 
  31.   color(0, 255, 255), 
  32.   color(255, 0, 0), 
  33.   color(255, 100, 0), 
  34.   color(255, 0, 255), 
  35.   color(0, 0, 255), //
  36.   color(255, 0, 255), 
  37.   color(255, 100, 0), 
  38.   color(255, 100, 0), 
  39.   color(0, 0, 255), 
  40.   color(0, 255, 0), 
  41.   color(0, 255, 0), 
  42.   color(100, 100, 100), 
  43.   color(255, 0, 0), 
  44.   color(100, 100, 100), 
  45.   color(255, 100, 0), 
  46.   color(0, 0, 255), 
  47.   color(255, 0, 255), 
  48.   color(0, 0, 0), 
  49.   color(0, 0, 255), 
  50.   color(255, 0, 0), 
  51.   color(200, 255, 0), 
  52.   color(255, 0, 255), 
  53.   color(0, 255, 255), 
  54.   color(255, 200, 0), 
  55.   color(255, 0, 255), 
  56.   color(0, 0, 255), 
  57.   color(0, 255, 0), 
  58.   color(0, 0, 255), 
  59.   color(255, 0, 0), 
  60.   color(255, 100, 0), 
  61.   color(0, 0, 255), 
  62.   color(255, 100, 0), 
  63.   color(0, 255, 255), 
  64.   color(0, 0, 255), 
  65.   color(0, 0, 255),
  66. };  

  67. float[] x, y, sz;
  68. int [] cursz;

  69. void setup() {
  70.   size(1000, 420);
  71.   smooth();
  72.   background(0);
  73.   noStroke();
  74.   colorMode(HSB, 360, 100, 100);
  75.   int n = 10;
  76.   x = new float[n];
  77.   y = new float[n];
  78.   sz = new float[n];
  79.   cursz = new int[n];
  80.   for (int i=0;i<x.length;i++) {
  81.     initShape(i);
  82.   }
  83. }

  84. void draw() {
  85.   for (int i = 0; i < x.length; i++) {
  86.     drawRing(frameCount, x[i], y[i], cursz[i]);
  87.     cursz[i]++;
  88.     if (cursz[i] > sz[i]) {
  89.       initShape(i);
  90.     }
  91.   }
  92.   noStroke();
  93.   fill(0, 0, 0, 5);
  94.   rect(0, 0, width, height);
  95. }

  96. void initShape(int i)
  97. {
  98.   int r = int(random(days.length));
  99.   x[i]  = hours[r]*40;//random(width);
  100.   y[i] = days[r]*70;// random(height);
  101.   sz[i] = likes[r]*2;//10  + random((width - 30)/ 3); 
  102.   cursz[i] = (int) sz[i] / 2;
  103. }

  104. void drawRing(int count, float x, float y, int sz)
  105. {
  106.   int hue = (count % 360 + (int) (x + y) ) % 360;
  107.   stroke(hue, 85, 95);
  108.   ellipse(x, y, sz, sz);
  109. }
Redefining your arrays of data every frame, by having them inside draw(), makes me want to pull my hair out and scream at you. Just have them globally.

If you want a different effect than this, you should be more specific about what kind of an effect you want.
This is just the effect I wanted! Thank you so much! and also for organizing it. The only thing is that I colors I firs sat had a meaning. So they can not be random as they are now. Could you also fix that?
Copy code
  1. int [] hours = {
  2.   10, 18, 11, 12, 20, 18, 17, 21, 19, 22, 19, 23, 17, 14, 16, 11, 18, 21, 13, 20, 11, 20, 1, 13, 11, 21, 23, 21, 19, 18, 14, 17, 14, 15, 20, 17, 21, 13, 14, 18, 9, 22, 17, 6, 19, 23, 16, 13, 15, 0, 17, 12, 14, 15, 18
  3. };
  4. int [] days = {
  5.   4, 4, 5, 6, 6, 0, 1, 2, 3, 4, 5, 5, 6, 0, 1, 2, 3, 4, 5, 5, 6, 0, 1, 1, 2, 3, 3, 4, 5, 6, 0, 1, 2, 3, 3, 4, 5, 6, 0, 1, 2, 4, 5, 6, 0, 1, 2, 3, 3, 4, 5, 0, 0, 1, 2
  6. };
  7. int [] likes = {
  8.   47, 44, 18, 14, 14, 19, 13, 7, 21, 7, 13, 37, 22, 32, 24, 13, 25, 15, 16, 8, 19, 16, 25, 7, 12, 6, 13, 11, 7, 15, 20, 20, 12, 17, 15, 36, 22, 23, 21, 18, 6, 17, 16, 20, 34, 12, 12, 36, 44, 14, 15, 17, 23, 13, 16
  9. };
  10. color [] tagg = {
  11.   color(255, 0, 0), 
  12.   color(255, 0, 0), 
  13.   color(255, 0, 0), 
  14.   color(255, 100, 0), 
  15.   color(0, 0, 255), 
  16.   color(255, 0, 255), 
  17.   color(0, 255, 255), 
  18.   color(255, 0, 255), 
  19.   color(0, 255, 0), 
  20.   color(0, 255, 255), 
  21.   color(255, 0, 255), 
  22.   color(0, 255, 0), 
  23.   color(200, 250, 0), 
  24.   color(0, 255, 0), 
  25.   color(0, 0, 255), 
  26.   color(255, 0, 255), 
  27.   color(0, 255, 255), 
  28.   color(255, 0, 255), 
  29.   color(255, 100, 0), 
  30.   color(255, 100, 0), 
  31.   color(0, 255, 255), 
  32.   color(255, 0, 0), 
  33.   color(255, 100, 0), 
  34.   color(255, 0, 255), 
  35.   color(0, 0, 255), //
  36.   color(255, 0, 255), 
  37.   color(255, 100, 0), 
  38.   color(255, 100, 0), 
  39.   color(0, 0, 255), 
  40.   color(0, 255, 0), 
  41.   color(0, 255, 0), 
  42.   color(100, 100, 100), 
  43.   color(255, 0, 0), 
  44.   color(100, 100, 100), 
  45.   color(255, 100, 0), 
  46.   color(0, 0, 255), 
  47.   color(255, 0, 255), 
  48.   color(0, 0, 0), 
  49.   color(0, 0, 255), 
  50.   color(255, 0, 0), 
  51.   color(200, 255, 0), 
  52.   color(255, 0, 255), 
  53.   color(0, 255, 255), 
  54.   color(255, 200, 0), 
  55.   color(255, 0, 255), 
  56.   color(0, 0, 255), 
  57.   color(0, 255, 0), 
  58.   color(0, 0, 255), 
  59.   color(255, 0, 0), 
  60.   color(255, 100, 0), 
  61.   color(0, 0, 255), 
  62.   color(255, 100, 0), 
  63.   color(0, 255, 255), 
  64.   color(0, 0, 255), 
  65.   color(0, 0, 255),
  66. };  

  67. float[] x, y, sz;
  68. int [] cursz;
  69. color [] colors;

  70. void setup() {
  71.   size(1000, 420);
  72.   smooth();
  73.   background(0);
  74.   noStroke();
  75.   //colorMode(HSB, 360, 100, 100);
  76.   int n = 10;
  77.   x = new float[n];
  78.   y = new float[n];
  79.   sz = new float[n];
  80.   cursz = new int[n];
  81.   colors = new color[n];
  82.   for (int i=0;i<x.length;i++) {
  83.     initShape(i);
  84.   }
  85. }

  86. void draw() {
  87.   for (int i = 0; i < x.length; i++) {
  88.     drawRing(frameCount, x[i], y[i], cursz[i], colors[i]);
  89.     cursz[i]++;
  90.     if (cursz[i] > sz[i]) {
  91.       initShape(i);
  92.     }
  93.   }
  94.   noStroke();
  95.   fill(0, 0, 0, 5);
  96.   rect(0, 0, width, height);
  97. }

  98. void initShape(int i)
  99. {
  100.   int r = int(random(days.length));
  101.   x[i]  = hours[r]*40;//random(width);
  102.   y[i] = days[r]*70;// random(height);
  103.   sz[i] = likes[r]*2;//10  + random((width - 30)/ 3); 
  104.   cursz[i] = (int) sz[i] / 2;
  105.   colors[i] = tagg[r];
  106. }

  107. void drawRing(int count, float x, float y, int sz, color theColor)
  108. {
  109.   //int hue = (count % 360 + (int) (x + y) ) % 360;
  110.   stroke(theColor);//hue, 85, 95);
  111.   ellipse(x, y, sz, sz);
  112. }
This can still probably be optimized in a few places.