@Override public Canvas clipRect(float x, float y, float width, float height) { bctx.clipToRect(new CGRect(x, y, width, height)); return this; }
@Override public Canvas clipRect(float x, float y, float width, float height) { bctx.clipToRect(new CGRect(x, y, width, height)); return this; }
@Override public Canvas fillRect(float x, float y, float width, float height) { RoboGradient gradient = currentState().gradient; if (gradient == null) { bctx.fillRect(new CGRect(x, y, width, height)); } else { bctx.saveGState(); bctx.clipToRect(new CGRect(x, y, width, height)); gradient.fill(bctx); bctx.restoreGState(); } isDirty = true; return this; }
@Override public Canvas fillRect(float x, float y, float width, float height) { RoboGradient gradient = currentState().gradient; if (gradient == null) { bctx.fillRect(new CGRect(x, y, width, height)); } else { bctx.saveGState(); bctx.clipToRect(new CGRect(x, y, width, height)); gradient.fill(bctx); bctx.restoreGState(); } isDirty = true; return this; }
@Override public void draw(CGBitmapContext bctx, 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 sx *= scale.factor; sy *= scale.factor; sw *= scale.factor; sh *= scale.factor; CGImage cgImage = cgImage(); float iw = cgImage.getWidth(), ih = cgImage.getHeight(); float scaleX = dw/sw, scaleY = dh/sh; // pesky fiddling to cope with the fact that UIImages are flipped bctx.saveGState(); bctx.translateCTM(dx, dy+dh); bctx.scaleCTM(1, -1); bctx.clipToRect(new CGRect(0, 0, dw, dh)); bctx.translateCTM(-sx*scaleX, -(ih-(sy+sh))*scaleY); bctx.drawImage(new CGRect(0, 0, iw*scaleX, ih*scaleY), cgImage); bctx.restoreGState(); }
@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 sx *= scale.factor; sy *= scale.factor; sw *= scale.factor; sh *= scale.factor; CGImage image = cgImage(); CGBitmapContext bctx = (CGBitmapContext)ctx; float iw = image.getWidth(), ih = image.getHeight(); float scaleX = dw/sw, scaleY = dh/sh; // pesky fiddling to cope with the fact that UIImages are flipped bctx.saveGState(); bctx.translateCTM(dx, dy+dh); bctx.scaleCTM(1, -1); bctx.clipToRect(new CGRect(0, 0, dw, dh)); bctx.translateCTM(-sx*scaleX, -(ih-(sy+sh))*scaleY); bctx.drawImage(new CGRect(0, 0, iw*scaleX, ih*scaleY), image); bctx.restoreGState(); }