//import processing.opengl.*; // digital acoustic cartography -------------------------------------------------------- // visualisation: anatomy // // 2005 daniel rothaug // mailto: daniel@acoustic-cartography.com // http://www.acoustic-cartoghraphy.com // // modified 2005-06-23 // p5 version: 91 int screenwidth = 800; int screenheight = 600; int imgheight = 350; // image heigth int imgwidth = 350; // image width int imgmargin = 43; // top and bottom image imgmargin int res; // resolution int mode; // default visualisation int fmode; // default frequency mode int nmznum; // default zoom int colormode; // default colormode int min = 58; // min db value int max = 78; // max db value int offset; int offnum; float o; int count = 0; int dx; int threshold = 5; float d, h, nmx, nmy, nmz; float rxnum; float rznum; float rx, rz; float dnum; PFont univers, supernatural; boolean autorotate = false; boolean showimage = false; boolean showbgimage = false; boolean showstage = true; boolean showdisplay = false; boolean showfilter = false; boolean showmarker = true; boolean showoutline = false; boolean showfrequencies = false; boolean showshortcuts = false; stage mystage = new stage(); display mydisplay = new display(); vimage vimage = new vimage(); PImage k; int add = 1; int img_num = 11; frequencies[] img = new frequencies[img_num]; markers mymarkers = new markers(); // setup ------------------------------------------------------------------------------------------ void setup() { background(0); size(screenwidth, screenheight, P3D); //lights(); // center position nmx = width/2; nmy = height/2 + 60; // load fonts univers = loadFont("Univers_57_Condensed.vlw"); supernatural = loadFont("Supernatural1002-Regular-10.vlw"); // load texture image vimage.load("texture.jpg"); k = loadImage("shortcuts.gif"); // init image sequence for(int i=0; i 0.1) { o += (offset-o)/1.5; nmy = height/2 + o*img.length/2; nmznum = int(100-o*4); } transform(); if (autorotate) { rznum += TWO_PI/72; } if (showimage || showmarker) { vimage.update(); } if (showimage) { vimage.render(); } if (showfilter) { mystage.layer(); } if (showfrequencies) { for(int i=1; i 0) { if (showstage) { mystage.freqscala(); } } else { if (showstage) { mystage.scala(); } } popMatrix(); // display if (showdisplay || mouseX < 20) { // show if (abs(mydisplay.open-dx) > 0.1) { dx += (mydisplay.open-dx)/1.5; } mydisplay.render(dx, 0); } else { // hide if (abs(mydisplay.closed-dx) > 0.1) { dx += (mydisplay.closed-dx)/1.5; } if (dx > -mydisplay.w) { mydisplay.render(dx, 0); }; } if (showshortcuts) { image(k, mydisplay.w + dx + 22, 22); } colorMode (HSB, 360, 100, 100, 100); stroke(0, 0, 30); noFill(); rect(0, 0, width-1, height-1); } // ----------------------------------------------------------------------------- // functions // ----------------------------------------------------------------------------- // 3D transformation ----------------------------------------------------------- void transform() { // drag if (mousePressed) { cursor(MOVE); if (abs(mouseX - nmx) > 0.01) { nmx += (mouseX-nmx)/6.0; } if (abs(mouseY - nmy) > 0.01) { nmy += (mouseY-nmy)/6.0; } } else { cursor(ARROW); } // zoom if (abs(nmz-nmznum) > 0.01) { nmz -= (nmz-nmznum)/2.0; }; // center translate(nmx, nmy, nmz); // x-axis rotation if (abs(rx-rxnum) > 0.01) { rx -= (rx-rxnum)/2.0; }; rotateX(rx); // z-axis rotation if (abs(rz-rznum) > 0.01) { rz -= (rz-rznum)/2.0; }; rotateZ(rz); // center again translate(-imgwidth/2, -imgwidth/2); // amplitude if (abs(d-dnum) > 0.01) { d -= (d-dnum)/2.0; }; } // convert color values int convertHSB (int i, int nn) { int min = 240; // lowest value int max = 305; // highest value int range = 360; // spectrum range int c; c = i * ( range - (range-max) ) / nn + (range-min); if (c > range) { c -= range; } return range - c; // mirror and return value }