/** * a wrapper around a PImage that knows how to get() and draw() itself for feedback * and track the mouse (in reverse) */ class MousedFeedbackTexture { PApplet applet; PGraphics g; PImage img; /** * intended for the OpenGL renderer, but will work with others */ MousedFeedbackTexture(PApplet applet) { this.applet = applet; this.g = applet.g; grab(); } void draw() { if (img==null) return; fill(255,245); stroke(0); pushMatrix(); translate(g.width/2f-mouseX+img.width/2f, g.height/2f-mouseY+img.height/2f, 0); beginShape(QUADS); texture(img); textureMode(NORMALIZED); // drawing at 140x140 is roughly equivalent to scale(1.1) when half screen // width/height == 128, just wanted to show another way of doing zoom in fx float dim = 140; vertex(-dim, -dim, 0, 0); vertex(dim, -dim, 1, 0); vertex(dim, dim, 1, 1); vertex(-dim, dim, 0, 1); endShape(); popMatrix(); } void grab() { img = g.get(); } }