/** Returns the supplied length scaled by our scale factor and rounded down. */ public int scaledFloor(float length) { return MathUtil.ifloor(scaled(length)); }
public RoboCanvas(RoboGLContext ctx, float width, float height, boolean interpolate) { super(width, height); // if our size is invalid, we'll fail below at CGBitmapContext, so fail here more usefully if (width <= 0 || height <= 0) throw new IllegalArgumentException( "Invalid size " + width + "x" + height); states.addFirst(new RoboCanvasState()); this.ctx = ctx; // create our raw image data texWidth = ctx.scale.scaledCeil(width); texHeight = ctx.scale.scaledCeil(height); // create the bitmap context via which we'll render into it bctx = RoboGraphics.createCGBitmap(texWidth, texHeight); if (!interpolate) { bctx.setInterpolationQuality(CGInterpolationQuality.None); } // clear the canvas before we scale our bitmap context to avoid artifacts bctx.clearRect(new CGRect(0, 0, texWidth, texHeight)); // CG coordinate system is OpenGL-style (0,0 in lower left); so we flip it bctx.translateCTM(0, ctx.scale.scaled(height)); bctx.scaleCTM(ctx.scale.factor, -ctx.scale.factor); }
/** Returns the supplied length scaled by our scale factor and rounded up. */ public int scaledCeil(float length) { return MathUtil.iceil(scaled(length)); }