public static int getComplementar(int original) { float R = Prototype.stage.red(original); float G = Prototype.stage.green(original); float B = Prototype.stage.blue(original); float minRGB = PApplet.min(R, PApplet.min(G, B)); float maxRGB = PApplet.max(R, PApplet.max(G, B)); float minPlusMax = minRGB + maxRGB; return Prototype.stage.color(minPlusMax - R, minPlusMax - G, minPlusMax - B); }
public void computeBounds() { PVector topLeft = points.get(0); PVector bottomRight = points.get(0); for (PVector v : points) { topLeft = new PVector(PApplet.min(topLeft.x, v.x), PApplet.min(topLeft.y, v.y)); bottomRight = new PVector(PApplet.max(bottomRight.x, v.x), PApplet.max(bottomRight.y, v.y)); } // bounds = new Rect(topLeft, bottomRight); }
public void setColorBuffers(PTexture[] textures, int n) { if (screenFb) return; if (numColorBuffers != PApplet.min(n, textures.length)) { throw new RuntimeException("Wrong number of textures to set the color buffers."); } for (int i = 0; i < numColorBuffers; i++) { colorBufferTex[i] = textures[i]; } pg.pushFramebuffer(); pg.setFramebuffer(this); // Making sure nothing is attached. for (int i = 0; i < numColorBuffers; i++) { pgl.glFramebufferTexture2D( PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0 + i, PGL.GL_TEXTURE_2D, 0, 0); } for (int i = 0; i < numColorBuffers; i++) { pgl.glFramebufferTexture2D( PGL.GL_FRAMEBUFFER, PGL.GL_COLOR_ATTACHMENT0 + i, colorBufferTex[i].glTarget, colorBufferTex[i].glID, 0); } pgl.validateFramebuffer(); pg.popFramebuffer(); }
protected void updateTexelsImpl(int x, int y, int w, int h) { int x2 = x + w; int y2 = y + h; if (!modified) { mx1 = PApplet.max(0, x); mx2 = PApplet.min(width - 1, x2); my1 = PApplet.max(0, y); my2 = PApplet.min(height - 1, y2); modified = true; } else { if (x < mx1) mx1 = PApplet.max(0, x); if (x > mx2) mx2 = PApplet.min(width - 1, x); if (y < my1) my1 = PApplet.max(0, y); if (y > my2) my2 = y; if (x2 < mx1) mx1 = PApplet.max(0, x2); if (x2 > mx2) mx2 = PApplet.min(width - 1, x2); if (y2 < my1) my1 = PApplet.max(0, y2); if (y2 > my2) my2 = PApplet.min(height - 1, y2); } }
/** @param theWindow */ void draw(ControlWindow theWindow) { // System.out.println(previousPosition+"\t"+currentPosition+"\t"+position); if (enabled) { if (mode >= Skatolo.WAIT) { previousPosition.set(currentPosition); currentPosition.set(theWindow.getPointerX(), theWindow.getPointerY(), 0); if (controller != null) { if (controller.getControlWindow().equals(theWindow)) { switch (mode) { case (Skatolo.WAIT): if (moved()) { startTime = System.nanoTime(); } if (System.nanoTime() > startTime + (delayInMillis * 1000000)) { position.set(currentPosition); alignH = Skatolo.RIGHT; if (position.x > (controller.getControlWindow().papplet().width - (getWidth() + 20))) { position.sub(new PVector(getWidth(), 0, 0)); alignH = Skatolo.LEFT; } mode = Skatolo.FADEIN; startTime = System.nanoTime(); currentAlpha = 0; } break; case (Skatolo.FADEIN): float t1 = System.nanoTime() - startTime; currentAlpha = (int) PApplet.map(t1, 0, 200 * 1000000, 0, maxAlpha); if (currentAlpha >= 250) { mode = Skatolo.IDLE; currentAlpha = 255; } break; case (Skatolo.IDLE): break; case (Skatolo.FADEOUT): float t2 = System.nanoTime() - startTime; currentAlpha = (int) PApplet.map(t2, 0, 200 * 1000000, maxAlpha, 0); if (currentAlpha <= 0) { mode = Skatolo.DONE; } break; case (Skatolo.DONE): controller = null; mode = Skatolo.INACTIVE; position.set(-1000, -1000, 0); } currentAlpha = PApplet.max(0, PApplet.min(currentAlpha, maxAlpha)); if (mode >= Skatolo.WAIT) { currentAlpha = (mode == Skatolo.WAIT) ? 0 : currentAlpha; theWindow.graphics().pushMatrix(); theWindow.graphics().translate(position.x, position.y); theWindow.graphics().translate(offset.x, offset.y); controllerView.display(theWindow.graphics(), null); // TODO: Warning HERE ! theWindow.graphics().popMatrix(); } if (mode < Skatolo.FADEOUT) { if (moved()) { deactivate(0); } } } } } } }
/** scroll the scrollList remotely. values must range between 0 and 1. */ public ListBox scroll(float theValue) { if ((items.size()) * _myItemHeight > _myBackgroundHeight) { _myScrollbar.setValue(PApplet.abs(1 - PApplet.min(PApplet.max(0, theValue), 1))); } return this; }
/** @param theWindow */ void draw(ControlWindow theWindow) { if (enabled) { if (_myMode >= ControlP5.WAIT) { previousPosition.set(currentPosition); currentPosition.set(theWindow.mouseX, theWindow.mouseY, 0); if (_myController != null) { if (_myController.getControlWindow().equals(theWindow)) { switch (_myMode) { case (ControlP5.WAIT): if (moved()) { startTime = System.nanoTime(); } if (System.nanoTime() > startTime + (_myDelayInMillis * 1000000)) { position.set(currentPosition); _myAlignH = ControlP5.RIGHT; if (position.x > (_myController.getControlWindow().papplet().width - (getWidth() + 20))) { position.sub(new PVector(getWidth(), 0, 0)); _myAlignH = ControlP5.LEFT; } _myMode = ControlP5.FADEIN; startTime = System.nanoTime(); _myAlpha = 0; } break; case (ControlP5.FADEIN): float t1 = System.nanoTime() - startTime; _myAlpha = (int) PApplet.map(t1, 0, 200 * 1000000, 0, _myMaxAlpha); if (_myAlpha >= 250) { _myMode = ControlP5.IDLE; _myAlpha = 255; } break; case (ControlP5.IDLE): break; case (ControlP5.FADEOUT): float t2 = System.nanoTime() - startTime; _myAlpha = (int) PApplet.map(t2, 0, 200 * 1000000, _myMaxAlpha, 0); if (_myAlpha <= 0) { _myMode = ControlP5.DONE; } break; case (ControlP5.DONE): _myController = null; _myMode = ControlP5.INACTIVE; position.set(-1000, -1000, 0); } _myAlpha = PApplet.max(0, PApplet.min(_myAlpha, _myMaxAlpha)); if (_myMode >= ControlP5.WAIT) { _myAlpha = (_myMode == ControlP5.WAIT) ? 0 : _myAlpha; theWindow.papplet().pushMatrix(); theWindow.papplet().translate(position.x, position.y); theWindow.papplet().translate(offset.x, offset.y); _myView.display(theWindow.papplet(), null); theWindow.papplet().popMatrix(); } if (_myMode < ControlP5.FADEOUT) { if (moved()) { deactivate(0); } } } } } } }