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); } }
protected void initTexture(int target, int format, int width, int height, int initColor) { int[] glcolor = new int[16 * 16]; Arrays.fill(glcolor, javaToNativeARGB(initColor)); IntBuffer texels = allocateDirectIntBuffer(16 * 16); texels.put(glcolor); texels.rewind(); for (int y = 0; y < height; y += 16) { int h = PApplet.min(16, height - y); for (int x = 0; x < width; x += 16) { int w = PApplet.min(16, width - x); texSubImage2D(target, 0, x, y, w, h, format, UNSIGNED_BYTE, texels); } } }
protected void initTexture(int target, int format, int width, int height, int initColor) { int[] glcolor = new int[16 * 16]; Arrays.fill(glcolor, javaToNativeARGB(initColor)); IntBuffer texels = allocateDirectIntBuffer(16 * 16); texels.put(glcolor); texels.rewind(); for (int y = 0; y < height; y += 16) { int h = PApplet.min(16, height - y); for (int x = 0; x < width; x += 16) { int w = PApplet.min(16, width - x); texSubImage2D(target, 0, x, y, w, h, format, UNSIGNED_BYTE, texels); } } }
public void stroke(int argb, int maxa) { int maxAlpha = PApplet.min(argb >> 24 & 0xFF, maxa); intf.app.stroke(argb >> 16 & 0xFF, argb >> 8 & 0xFF, argb & 0xFF, getAlpha(maxAlpha)); }
public void fill(int argb, int maxa) { int maxAlpha = PApplet.min(argb >> 24 & 0xFF, maxa); intf.app.fill(argb >> 16 & 0xFF, argb >> 8 & 0xFF, argb & 0xFF, getAlpha(maxAlpha)); }
public void tint(int argb, int maxa) { int maxAlpha = PApplet.min(argb >> 24 & 0xFF, maxa); intf.app.tint(argb >> 16 & 0xFF, argb >> 8 & 0xFF, argb & 0xFF, getAlpha(maxAlpha)); }
public int getAlpha(int max) { if (parent != null && inner) { // Constraining by the opacity of the parent in case this is an "inner" // widget. max = PApplet.min(max, parent.getAlpha(255)); } return PApplet.round(opacity.get() * max); }
boolean inside(float rx, float ry) { textFont(pFont); float w1 = textWidth(label); if (w1 < width/2 - w) { w1 = PApplet.min(WIDTH_FACTOR * w1, width/2 - w); } float x1 = x + w + 5 + w1; float y1 = y.get() + h + sep; return x <= rx && rx <= x1 && y.get() <= ry && ry <= y1; }
protected void initTexture(PGraphicsOpenGL pg, PFont font) { lastTex = -1; int spow = PGL.nextPowerOfTwo(font.getSize()); minSize = PApplet.min(PGraphicsOpenGL.maxTextureSize, PApplet.max(PGL.MIN_FONT_TEX_SIZE, spow)); maxSize = PApplet.min(PGraphicsOpenGL.maxTextureSize, PApplet.max(PGL.MAX_FONT_TEX_SIZE, 2 * spow)); if (maxSize < spow) { PGraphics.showWarning("The font size is too large to be properly " + "displayed with OpenGL"); } addTexture(pg); offsetX = 0; offsetY = 0; lineHeight = 0; texinfoMap = new HashMap<PFont.Glyph, TextureInfo>(); glyphTexinfos = new TextureInfo[font.getGlyphCount()]; addAllGlyphsToTexture(pg, font); }
@Override public boolean save(String filename) { // ignore if (hints[DISABLE_ASYNC_SAVEFRAME]) { return super.save(filename); } if (asyncImageSaver == null) { asyncImageSaver = new AsyncImageSaver(); } if (!loaded) loadPixels(); PImage target = asyncImageSaver.getAvailableTarget(pixelWidth, pixelHeight, format); if (target == null) return false; int count = PApplet.min(pixels.length, target.pixels.length); System.arraycopy(pixels, 0, target.pixels, 0, count); asyncImageSaver.saveTargetAsync(this, target, filename); return true; }
@Override public boolean save(String filename) { // ignore if (hints[DISABLE_ASYNC_SAVEFRAME]) { return super.save(filename); } if (asyncImageSaver == null) { asyncImageSaver = new AsyncImageSaver(); } if (!loaded) loadPixels(); PImage target = asyncImageSaver.getAvailableTarget(pixelWidth, pixelHeight, format); if (target == null) return false; int count = PApplet.min(pixels.length, target.pixels.length); System.arraycopy(pixels, 0, target.pixels, 0, count); asyncImageSaver.saveTargetAsync(this, target, parent.sketchFile(filename)); return true; }
void mouseReleased() { if (!inside(mouseX, mouseY)) return; if (insideDismiss(mouseX, mouseY)) { data.removeCovariate(var); markedForRemoval = true; } else { open = !open; if (open) { float h1 = PApplet.min(covarHeightMax, itemHeight + posy + selector.getFullHeight() + marginy); y.setTarget(-(h1 - itemHeight)); h.setTarget(h1); selector.targetY(y.getTarget() + itemHeight + posy); selector.setHeight(h1 - itemHeight - posy); } else { y.setTarget(0); h.setTarget(itemHeight); selector.targetY(itemHeight + posy); selector.setHeight(selh); } } }