/** Returns the supplied length inverse scaled by our scale factor and rounded down. */ public int invScaledFloor(float length) { return MathUtil.ifloor(invScaled(length)); }
/** * Adds {@code child} to this group layer, adjusting its translation (relative to this group * layer) to {@code floor(tx), floor(ty)}. This is useful for adding layers which display text a * text can become blurry if it is positioned on sub-pixel boundaries. */ public void addFloorAt (Layer child, float tx, float ty) { add(child.setTranslation(MathUtil.ifloor(tx), MathUtil.ifloor(ty))); }
/** Returns the supplied length scaled by our scale factor and rounded down. */ public int scaledFloor(float length) { return MathUtil.ifloor(scaled(length)); }
/** Returns the supplied length scaled by our scale factor and rounded down. */ public int scaledFloor(float length) { return MathUtil.ifloor(scaled(length)); }
/** Returns the supplied length inverse scaled by our scale factor and rounded down. */ public int invScaledFloor(float length) { return MathUtil.ifloor(invScaled(length)); }
/** Returns the supplied length inverse scaled by our scale factor and rounded down. */ public int invScaledFloor(float length) { return MathUtil.ifloor(invScaled(length)); }
/** Returns the supplied length scaled by our scale factor and rounded down. */ public int scaledFloor(float length) { return MathUtil.ifloor(scaled(length)); }
@Override protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY, float x, float y, float width, float height) { int ix = MathUtil.ifloor(x), iy = MathUtil.ifloor(y); int iw = MathUtil.iceil(width), ih = MathUtil.iceil(height); return new AndroidPattern(image, repeatX, repeatY, Bitmap.createBitmap(bitmap, ix, iy, iw, ih)); }
@Override protected Pattern toSubPattern(AbstractImageGL<?> image, boolean repeatX, boolean repeatY, float x, float y, float width, float height) { int ix = MathUtil.ifloor(x), iy = MathUtil.ifloor(y); int iw = MathUtil.iceil(width), ih = MathUtil.iceil(height); return new AndroidPattern(image, repeatX, repeatY, Bitmap.createBitmap(bitmap, ix, iy, iw, ih)); }
@Override public Canvas clipRect(float x, float y, float width, final float height) { final int cx = MathUtil.ifloor(x), cy = MathUtil.ifloor(y); final int cwidth = MathUtil.iceil(width), cheight = MathUtil.iceil(height); currentState().clipper = new JavaCanvasState.Clipper() { public void setClip(Graphics2D g2d) { g2d.setClip(cx, cy, cwidth, cheight); } }; return this; }
@Override public Canvas clipRect(float x, float y, float width, final float height) { final int cx = MathUtil.ifloor(x), cy = MathUtil.ifloor(y); final int cwidth = MathUtil.iceil(width), cheight = MathUtil.iceil(height); currentState().clipper = new JavaCanvasState.Clipper() { public void setClip(Graphics2D gfx) { gfx.clipRect(cx, cy, cwidth, cheight); } }; return this; }
@Override public Canvas clipRect(float x, float y, float width, final float height) { final int cx = MathUtil.ifloor(x), cy = MathUtil.ifloor(y); final int cwidth = MathUtil.iceil(width), cheight = MathUtil.iceil(height); currentState().clipper = new JavaCanvasState.Clipper() { public void setClip(Graphics2D g2d) { g2d.setClip(cx, cy, cwidth, cheight); } }; return this; }
@Override public Canvas clipRect(float x, float y, float width, final float height) { final int cx = MathUtil.ifloor(x), cy = MathUtil.ifloor(y); final int cwidth = MathUtil.iceil(width), cheight = MathUtil.iceil(height); currentState().clipper = new JavaCanvasState.Clipper() { public void setClip(Graphics2D gfx) { gfx.clipRect(cx, cy, cwidth, cheight); } }; return this; }
@Override public void draw (Object ctx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { // adjust our source rect to account for the scale factor float f = scale().factor; sx *= f; sy *= f; sw *= f; sh *= f; // now render the image through a clip and with a scaling transform, so that only the desired // source rect is rendered, and is rendered into the desired target region float scaleX = dw/sw, scaleY = dh/sh; Graphics2D gfx = (Graphics2D)ctx; Shape oclip = gfx.getClip(); gfx.clipRect(MathUtil.ifloor(dx), MathUtil.ifloor(dy), MathUtil.iceil(dw), MathUtil.iceil(dh)); gfx.drawImage(img, new AffineTransform(scaleX, 0f, 0f, scaleY, dx-sx*scaleX, dy-sy*scaleY), null); gfx.setClip(oclip); }
@Override public void draw (Object ctx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { // adjust our source rect to account for the scale factor float f = scale().factor; sx *= f; sy *= f; sw *= f; sh *= f; // now render the image through a clip and with a scaling transform, so that only the desired // source rect is rendered, and is rendered into the desired target region float scaleX = dw/sw, scaleY = dh/sh; Graphics2D gfx = (Graphics2D)ctx; Shape oclip = gfx.getClip(); gfx.clipRect(MathUtil.ifloor(dx), MathUtil.ifloor(dy), MathUtil.iceil(dw), MathUtil.iceil(dh)); gfx.drawImage(img, new AffineTransform(scaleX, 0f, 0f, scaleY, dx-sx*scaleX, dy-sy*scaleY), null); gfx.setClip(oclip); }
@Override protected Instance instantiate (IDimension size) { final float x = MathUtil.ifloor((size.width()-tile.width())/2); final float y = MathUtil.ifloor((size.height()-tile.height())/2); return new LayerInstance(size, new Layer() { protected void paintImpl (Surface surf) { surf.draw(tile, x, y); } }); } };