Made some pretty progress.
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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
/* * 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 = 720; // 768 / 720 / 480 / 350 // load Open Sound Contol library OSCP5 import oscP5.*; import netP5.*; OscP5 oscP5; // init int bgColorH, bgColorS, bgColorB, bgColorA = 50; int flickCount = 2; // 2,3,4 or 5 // image pool // PImage array imgPool[] // 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; // image blender "ibl" variables boolean iblOn = true; PImage iblImg1; int iblNum=1; float iblX=0, iblY=0, iblWidth=600, iblHeight=100; float iblRot; // radians need a float float iblSpeedX, iblSpeedY; float iblSpeedXfactor = 0, iblSpeedYfactor = 0; float iblTexX, iblTexY, iblTexWidth, iblTexHeight; float iblTexSpeedX, iblTexSpeedY; float iblTexSpeedXfactor = 0, iblTexSpeedYfactor = 0; int iblH, iblS=0, iblB=100, iblA=255; // stroke color / tint int iblBflicker=0; // flicker (Brightness) float iblItX=0, iblItY=0, iblItTexX=0, iblItTexY=0, iblItRot; // prepare PFont datatype for a font for on-screen debug PFont font; // SETUP //////////////////////////////////////////////////////////////// void setup() { // set size of the window & renderer size(windowHeight/9*16, windowHeight // screen should be 16:9 , P3D // renderer P3D, P2D or commented out for default Java2D? ); // set location of the window // frame.setLocation(0,0); // background colour background(0); // framerate frameRate(60); // antialiasing? //noSmooth(); 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 // iblender iblImg1 = loadImage("test_image18.png"); // 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 (val == 2) { iblOn = false; } if (val == 3) { iblOn = true; } if (val > 3 && val < 8) { flickCount = val - 2; } // flicker count } // flying lines if (cc == 2) { flySpeedXfactor = (val - 64); } // speed (&direction) on X axis [-1 - 1] FIXit! if (cc == 3) { flySpeedYfactor = (val - 64); } // speed (&direction) on Y axis [-1 - 1] FIXit! 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, size of primitive geo? 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; } // image blender ibl if (cc == 30) { iblH = int(val * 2.8346); } // stroke HUE (0-360) if (cc == 31) { iblS = int(val * 0.787); } // stroke SATURATION [0-100] if (cc == 32) { iblB = int(val * 0.787); } // stroke BRIGHTNESS [0-100] if (cc == 33) { iblA = val * 2; } // stroke ALPHA [0-254] if (cc == 34) { iblX = int( ((val-64) / 64.0) * width/2 ); } if (cc == 35) { iblY = int( ((val-64) / 64.0) * height/2 ); } if (cc == 36) { iblWidth = int(val * val * 0.05 * norm(width, 0, width)); } if (cc == 37) { iblHeight = int(val * val * 0.03 * norm(height, 0, height)); } // exponental if (cc == 38) { iblRot = radians(val * 360 / 120); } // rotation if (cc == 39) { iblSpeedXfactor = ((val-64) * abs(val-64) * 0.6); } // autonomous movement X if (cc == 40) { iblSpeedYfactor = ((val-64) * abs(val-64) * 0.6); } // ------- " --------- Y if (cc == 41) { iblTexX = ((val - 64) / 64.0) * 1920 / 2; } // texture offset from position if (cc == 42) { iblTexY = ((val - 64) / 64.0) * 1080 / 2; } if (cc == 43) { iblTexWidth = (val - 64) * val ; } if (cc == 44) { iblTexHeight = (val - 64) * val ; } if (cc == 45) { iblTexSpeedXfactor = ((val-64) * abs(val-64) * 0.6) ; } if (cc == 46) { iblTexSpeedYfactor = ((val-64) * abs(val-64) * 0.6) ; } if (cc == 47) { iblBflicker = int(val * 0.787); }; if (cc == 48) { iblNum = constrain(val, 1, 127); } // number of iterations if (cc == 49) { iblItX = (val-64) * abs(val-64) * 0.1; } if (cc == 50) { iblItY = (val-64) * abs(val-64) * 0.1; } if (cc == 51) { iblItTexX = val*4; } if (cc == 52) { iblItTexY = val*4; } if (cc == 53) { iblItRot = radians(val * 0.2); } } // main draw loop - every frame! void draw() { colorMode(HSB, 360, 100, 100); // for the whole draw! fill(bgColorH, bgColorS, bgColorB, bgColorA); noStroke(); rect(0, 0, width+1, height+1); // image blender ibl //////////////////////////////////////////////////////////////// if (iblOn == true) { // on off control pushMatrix(); translate(width/2, height/2); // center coordinate system // autonomous movement iblSpeedX = 0.1; iblSpeedY = 0.1; iblSpeedX *= iblSpeedXfactor; iblSpeedY *= iblSpeedYfactor; iblX += iblSpeedX; iblY += iblSpeedY; if (iblX > width) { iblX = -width; } if (iblX < -width) { iblX = width; } if (iblY > height) { iblY = -height; } if (iblY < -height) { iblY = height; } iblTexSpeedX = 0.1; iblTexSpeedY = 0.1; iblTexSpeedX *= iblTexSpeedXfactor; iblTexSpeedY *= iblTexSpeedYfactor; iblTexX += iblTexSpeedX; iblTexY += iblTexSpeedY; int iblBflicked; if (frameCount % flickCount == 1) { iblBflicked = iblB - iblBflicker; } else { iblBflicked = iblB; } for (int i=0; i < iblNum; i++) { // draw in an independent coordinate system pushMatrix(); // XY = translate translate(iblX + i*iblItX, iblY + i*iblItY); rotate(iblRot + (i*iblItRot)); textureWrap(REPEAT); // draw the quad beginShape(); tint(iblH, iblS, iblBflicked, iblA); //tint(200,255,255); texture(iblImg1); vertex(-iblWidth, -iblHeight, // X & Y of the vertex width/2 - iblWidth + iblX + iblTexX + (i*iblItTexX) - iblTexWidth, // X of the texture height/2 - iblHeight + iblY + iblTexY + (i*iblItTexY) - iblTexHeight); // Y of the texture vertex(iblWidth, -iblHeight, width/2 + iblWidth + iblX + iblTexX + (i*iblItTexX) + iblTexWidth, height/2 - iblHeight + iblY + iblTexY + (i*iblItTexY) - iblTexHeight); vertex(iblWidth, iblHeight, width/2 + iblWidth + iblX + iblTexX + (i*iblItTexX) + iblTexWidth, height/2 + iblHeight + iblY + iblTexY + (i*iblItTexY) + iblTexHeight); vertex(-iblWidth, iblHeight, width/2 - iblWidth + iblX + iblTexX + (i*iblItTexX) - iblTexWidth, height/2 + iblHeight + iblY + iblTexY + (i*iblItTexY) + iblTexHeight); endShape(); popMatrix(); // end independent coordinate system } popMatrix(); /* //** debug **************************** fill(0,125); rect(0, 0, 200, 30); fill(255); text(iblTexSpeedXfactor, 5, 30); //text(iblSpeedXfactor, 20, 60); */ } // 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); } // 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); popMatrix(); } } } // end of draw() |