Current state of Processing sketch for my AV performance “Interface fractures II: Metal”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
/* * Interface fractures: METAL * copyleft nova@deviator.si */ // undecorate window public void init() { frame.removeNotify(); frame.setUndecorated(true); frame.addNotify(); super.init(); } // screen should always be 16:9, // so define height here and the rest is calculated int windowHeight = 480; // 768 / 720 / 480 / 350 // load Open Sound Contol library OSCP5 import oscP5.*; import netP5.*; OscP5 oscP5; // init int bgColorH, bgColorS, bgColorB, bgColorA = 255; // flying dots variables boolean flyOn = false; int flyDotsNum = 1000; float[] flyX = new float[flyDotsNum]; float[] flyY = new float[flyDotsNum]; PImage flyDimg1; float flySpeedXfactor = -5; float flySpeedYfactor = -5; float flyRotation = 0; float flyRotationPixAmount = 0.0; float flySize = 10; int flyStrokeW = 1; float flyStrokePix = 0; float flyTransparent = 255; float flyColorFixedGray = 255; // gray value float flyColorPix = 0; // amount of pix color influence [0-1] float flyColorH = 360, flyColorS = 0, flyColorB = 100, flyColorA = 127; // on-screen debug // PFont font; // SETUP //////////////////////////////////////////////////////////////// void setup() { size(windowHeight/9*16, windowHeight, P3D); // screen should be 16:9 // set location of the window // frame.setLocation(0,0); // background colour background(0); // framerate frameRate(60); // antialiasing smooth(); // start oscP5, listening for incoming messages at port 12000 oscP5 = new OscP5(this,12000); oscP5.plug(this,"ctlin","/ctlin"); // to be converted for PD OSC input // flying dots flyDimg1 = loadImage("test_image18.png"); // load the image for flying dots // generate random coordinates for starting point... for (int i = 0; i < flyDotsNum; i++) { flyX[i] = random(width); flyY[i] = random(height); } stroke(255); // color of the dots // debug onscreen fonts // font = loadFont("UbuntuMono-Regular-14.vlw"); // textFont(font); } // process renoise MIDI/OSC messages public void ctlin(int cc, int val) { // debug println("## OSC: /ctlin cc:" + cc + " value:" + val); // triggers are on controller number 0 if (cc == 0) { if (val == 0) { flyOn = false; } if (val == 1) { flyOn = true; } } if (cc == 2) { flySpeedXfactor = (val - 64); } // speed (&direction) on X axis if (cc == 3) { flySpeedYfactor = (val - 64); } // speed (&direction) on Y axis if (cc == 4) { flyRotation = radians(val * 360 / 127); } // hard rotation of each line if (cc == 12) { flyRotationPixAmount = val * 0.2; } // rotation pixel influence amount [0-1] if (cc == 5) { flySize = val * 2; } // length of line if (cc == 10) { flyStrokeW = int(val); } // stroke Weight if (cc == 13) { flyStrokePix = val; } if (cc == 6) { bgColorH = int(val * 2.8346); } // background color HUE [0 - 360] if (cc == 7) { bgColorS = int(val * 0.787); } // background color SATURATION [0-100] if (cc == 8) { bgColorB = int(val * 0.787); } // background colorBRIGHTNESS [0-100] if (cc == 9) { bgColorA = int(val) * 2; } // background ALPHA [0-254] if (cc == 14) { flyColorA = val * 2; } // transparency of lines if (cc == 15) { flyColorH = int (val * 2.8346); } // background color HUE [0 - 360] if (cc == 16) { flyColorS = int(val * 0.787); } // background color SATURATION [0-100] if (cc == 17) { flyColorB = int(val * 0.787); } // background colorBRIGHTNESS [0-100] if (cc == 18) { flyColorPix = val / 127.0; } } // main draw loop - every frame! void draw() { colorMode(HSB, 360, 100, 100); fill(bgColorH, bgColorS, bgColorB, bgColorA); noStroke(); rect(0, 0, width+1, height+1); // flying dots ////////////////////////////////////////////////////////////////////// if (flyOn == true) { for (int i = 0; i < flyDotsNum; i++) { // for each dot: // colors color flyC = flyDimg1.get(int(flyX[i]), int(flyY[i])); // get color of the pixel // get HSBA data for that pixel float flyPixH = hue(flyC); float flyPixS = saturation(flyC); float flyPixB = brightness(flyC); float flyPixA = alpha(flyC); float flyB = flyPixB / 255.0; // move brightness to 0 - 1 range // color strokeColor = color( flyColorH * flyColorPix + flyPixH * (1-flyColorPix), flyColorS * flyColorPix + flyPixS * (1-flyColorPix), flyColorB * flyColorPix + flyPixB * (1-flyColorPix), flyColorA * flyColorPix + flyPixA * (1-flyColorPix) ); // movement: speed and direction float flySpeedX = pow(flyB, 2) + 0.05; // define speed from brightness float flySpeedY = pow(flyB, 2) + 0.05; flySpeedX *= flySpeedXfactor; flySpeedY *= flySpeedYfactor; flyX[i] += flySpeedX; // movement on X axis flyY[i] += flySpeedY; float flySizeB = flySize * flyB; if (flyX[i] > width ) { // if off-screen: flyX[i] = 0; // wrap back flyY[i] = random(height); // randomize Y-axis position } else if (flyX[i] < 0) { flyX[i] = width; flyY[i] = random(height); } if (flyY[i] > height) { flyY[i] = 0; flyX[i] = random(width); } else if (flyY[i] < 0) { flyY[i] = height; flyX[i] = random(width); } //colorMode(HSB, 360, 100, 100); // draw in an independent coordinate system pushMatrix(); stroke(strokeColor); // stroke color&transparency strokeWeight(flyStrokeW + (flyB * flyStrokePix)); // strokeWeight(flyB*10); translate(flyX[i], flyY[i]); rotate(flyRotation + (flyB * flyRotationPixAmount)); line(-flySizeB, -flySizeB, flySizeB, flySizeB); //fill(#0000ff); //text(flyRotationInt, 0, 0); popMatrix(); } } } // end of draw() |