PFont uifont; UIScrollbar [] bars; UIButton [] buts; void UIInit() { uifont = loadFont("small-6.vlw"); bars = new UIScrollbar[2]; buts = new UIButton[4]; bars[0] = new UIScrollbar(10, 307, "BRIGHTNESS"); bars[1] = new UIScrollbar(10, 324, "BLUR RADIUS"); buts[0] = new UIButton(200, 305, 40, 30, "mossy.jpg"); buts[1] = new UIButton(250, 305, 40, 30, "creek.jpg"); buts[2] = new UIButton(300, 305, 40, 30, "kateb.jpg"); buts[3] = new UIButton(350, 305, 40, 30, "billc.jpg"); Reprocess(buts[0].img); } void Reprocess(PImage img) { if (img != null) source = img; int briteness = bars[0].pos; float blurradius = 1f + bars[1].pos * 0.1f; ortonized = Ortonize(source, briteness, blurradius); } void UIUpdate() { if (bars[0].update() || bars[1].update()) Reprocess(null); for (int i=0; i=x1) && (y>=y1) && (x<=x2) && (y<=y2)); } class UIScrollbar { int x, y, w, h, pos; float lo, hi, span; String caption; UIScrollbar(int x, int y, String cap) { this.x = x; this.y = y; this.w = 108; this.h = 8; this.pos = 50; this.caption = cap; } boolean update() { boolean over = within(mouseX, mouseY, x, y, x+w-1, y+h-1); if (over && mousePressed) { pos = constrain(mouseX-x-3, 0, 100); return true; } return false; } void draw() { fill(#EEEEEE); stroke(#666666); rect(x, y, w, h); stroke(#999999); fill(#AAAAAA); rect(x+1+pos, y+1, 6, 6); textFont(uifont); fill(#666666); text(caption, x+2, y+h-1); } } class UIButton { int x, y, w, h; String imgfilename; PImage img; boolean pressed; UIButton(int x, int y, int w, int h, String filename) { this.x = x; this.y = y; this.w = w; this.h = h; this.imgfilename = filename; this.img = loadImage(filename); } boolean update() { boolean over = within(mouseX, mouseY, x, y, x+w-1, y+h-1); boolean waspressed = pressed; pressed = (over && mousePressed); return ((!waspressed) && (pressed)); } void draw() { image(img, x, y, w, h); noFill(); stroke(#666666); rect(x, y, w, h); } }