Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PRE-SETUP//
- //mic_minim//
- import ddf.minim.*;
- Minim minim;
- AudioInput in;
- float volumeIn; //Input value × 1000
- float d; //diameter
- float sa; //The difference between the input value × 1000 and the current diameter
- float easing = 0.1; //The easing coefficient, large numerical value changes greatly
- PImage head;
- //array//
- ArrayList p;
- int move = 0;
- float speed = 0.2;
- float accel = 1.01;
- //VOID SETUP//
- void setup()
- {
- //mic_setup//
- size(1280, 800);
- minim = new Minim(this);
- in = minim.getLineIn(Minim.MONO, 512);
- fill(200,0,20,100);
- //img_setup1//
- PImage head;
- head = loadImage("doge.png");
- //array_setup//
- int x, y;
- color a;
- frameRate(60);
- background(0); // !!!! Do i have to state the backround here? !!!!
- //img_setup_for_array//
- image(head,width/2,height/2); // /!!!Do i have to state the position here? !!!!
- imageMode(CENTER);
- a=color(0);
- p = new ArrayList();
- for (x=0; x<width; x=x+1) {
- for (y=0; y<height; y=y+1) {
- if (get(x, y)!=a) {
- p.add(new pxl (x, y, random(-speed, speed), random(-speed, speed), get(x, y)));
- }
- }
- }
- }
- /// VOID_DRAW///
- void draw() {
- //mic_draw//
- volumeIn = map(in.left.level(), 0, 0.5, 0, width*2); /// Convert input value to 0 to 500
- sa = volumeIn - d; //difference between the input value and the current diameter
- if(abs(sa) > 1) { //change the diameter only when the absolute value of the difference is greater than 1
- d = d + sa * easing; //0.1 min change in difference
- }
- image (head,width/2,height/2,d,d); // image size depends on the diameter
- int i;
- pxl a;
- background(0); // !!! Do i have to state the backround here again --not sure !!!
- for (i=0; i<p.size(); i=i+1) {
- a = (pxl) p.get(i);
- a.update(move);
- }
- }
- /// CLASS_PIXEL///
- class pxl {
- float xspeed, yspeed;
- float x, y;
- color p;
- pxl (int a, int b, float c, float d, color e) {
- x = float(a);
- y = float(b);
- xspeed = c;
- yspeed = d;
- p = e;
- }
- /// VOID_UPDATE///
- void update(int move) { // how its exploded
- if (move==1) {
- xspeed=xspeed*accel;
- yspeed=yspeed*accel;
- x = x + xspeed;
- y = y + yspeed;
- }
- set(int(x), int(y), p);
- }
- }
- void explode() { // !!! I want to a statement that the picture should be exploded, if the picture radius/pixel more than 500 x 500 px
- if (head = 500,500) {
- move = 1;
- }
- }
- void mousePressed() {
- redraw();
- }
- void stop() {
- in.close();
- minim.stop();
- super.stop();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement