/* This is the second part of building a 4-step Sequencer Synthesizer modeling the one found at : http://www.handmadeelectronicinstruments.com/store/product/four-step-sequencer-synthesizer/ In this step we add some interaction to the images. In particular, we turn the knobs and switches into two classes and allow interaction via the mouse. Andy Sarroff, 2/2014 */ PImage bgimg; PImage ledOn; PImage ledOff; PImage swOn; PImage swOff; int zone; Control[] controls = new Control[7]; Switch[] switches = new Switch[5]; void setup() { size(692, 346); // http://img.ehowcdn.com/default/ehow/images/a07/fd/m6/types-brushed-aluminum-sheets-1.1-800x800.jpg bgimg = loadImage("aluminum.jpg"); bgimg.resize(bgimg.width*2, bgimg.height); // Load images imageMode(CENTER); // http://openclipart.org/image/300px/svg_to_png/88123/led_red_black.png ledOn = loadImage("led.png"); ledOn.resize(ledOn.width/10, 0); ledOff = loadImage("ledOff.png"); ledOff.resize(ledOff.width/10, 0); // http://www.yourpowercentre.com.au/wp-content/uploads/2013/10/switch.jpg swOn = loadImage("swOn.png"); swOn.resize(swOn.width/3, 0); swOff = loadImage("swOff.png"); swOff.resize(swOff.width/3, 0); // http://578e7a9bafc08e847f59-b21544d490ba797ec9de9d17e947de3d.r81.cf1.rackcdn.com/lrs-18519e_7379.jpg PImage img = loadImage("knob_t.png"); img.resize(img.width/4, 0); // Set size of window to match background image background(bgimg); // Initialize controls for (int i=0; i= 2 && zone <=3) { controls[zone-1].update(); } else if (zone >=8 && zone <= 11) { controls[zone-5].update(); } } void mousePressed() { // We use void mousePressed(), which gets called only once for each mouse // press. This way the zone is updated only once per mouse press. We // additionally use this function to flip the on/off switch getZone(); if (zone == 1) { switches[4].on = !switches[4].on; } } // START NO NOTES // code used to capture screenshots void keyReleased() { boolean online = true; if (key == '`' && !online) save("sketch.png"); }