@Override public Canvas drawArc(float cx, float cy, float r, float startAngle, float arcAngle) { // Note: https://developer.apple.com/documentation/coregraphics/1455756-cgcontextaddarc // "In a flipped coordinate system (the default for UIView drawing methods // in iOS), specifying a clockwise arc results in a counterclockwise arc // after the transformation is applied." int cw = (arcAngle > 0) ? 1 : 0; bctx.beginPath(); bctx.addArc(cx, cy, r, -startAngle, -(startAngle + arcAngle), cw); bctx.strokePath(); isDirty = true; return this; }
@Override public Canvas drawLine(float x0, float y0, float x1, float y1) { bctx.beginPath(); bctx.moveToPoint(x0, y0); bctx.addLineToPoint(x1, y1); bctx.strokePath(); isDirty = true; return this; }
@Override public Canvas drawLine(float x0, float y0, float x1, float y1) { bctx.beginPath(); bctx.moveToPoint(x0, y0); bctx.addLineToPoint(x1, y1); bctx.strokePath(); isDirty = true; return this; }
private void addRoundRectPath(float x, float y, float width, float height, float radius) { float midx = x + width/2, midy = y + height/2, maxx = x + width, maxy = y + height; bctx.beginPath(); bctx.moveToPoint(x, midy); bctx.addArcToPoint(x, y, midx, y, radius); bctx.addArcToPoint(maxx, y, maxx, midy, radius); bctx.addArcToPoint(maxx, maxy, midx, maxy, radius); bctx.addArcToPoint(x, maxy, x, midy, radius); bctx.closePath(); }
private void addRoundRectPath(float x, float y, float width, float height, float radius) { float midx = x + width/2, midy = y + height/2, maxx = x + width, maxy = y + height; bctx.beginPath(); bctx.moveToPoint(x, midy); bctx.addArcToPoint(x, y, midx, y, radius); bctx.addArcToPoint(maxx, y, maxx, midy, radius); bctx.addArcToPoint(maxx, maxy, midx, maxy, radius); bctx.addArcToPoint(x, maxy, x, midy, radius); bctx.closePath(); }