@Override public Canvas arc(int x, int y, int radius, double startAngle, double endAngle) { addOperation(() -> context2d.arc(x, y, radius, startAngle, endAngle)); return this; }
@Override public Canvas drawArc(float cx, float cy, float r, float startAngle, float arcAngle) { boolean ccw = arcAngle > 0; ctx.beginPath(); ctx.arc(cx, cy, r, -startAngle, -(startAngle + arcAngle), ccw); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas fillCircle(float x, float y, float radius) { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); ctx.fill(); isDirty = true; return this; }
@Override public Canvas fillCircle(float x, float y, float radius) { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); ctx.fill(); isDirty = true; return this; }
@Override public Canvas fillCircle(float x, float y, float radius) { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); ctx.fill(); isDirty = true; return this; }
@Override public Canvas strokeCircle(float x, float y, float radius) { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas drawArc(float cx, float cy, float r, float startAngle, float arcAngle) { boolean ccw = arcAngle > 0; ctx.beginPath(); ctx.arc(cx, cy, r, -startAngle, -(startAngle + arcAngle), ccw); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas strokeCircle(float x, float y, float radius) { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas strokeCircle(float x, float y, float radius) { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); ctx.stroke(); isDirty = true; return this; }
@Override public void draw( Context2d ctx, double x, double y, double radius ) { ctx.beginPath(); ctx.arc( x, y, radius, 0, Math.PI, false ); ctx.moveTo( x - radius, y ); ctx.lineTo( x + radius, y ); ctx.stroke(); } }
private void drawGradient(final boolean drawHandle) { final Context2d ctx = canvas.getContext2d(); // draw gradient final Hsl hsl = new Hsl(hue, 0, 50); for (int x = 0; x <= 179; x++) { hsl.setS(Math.round(x * 100 / 179)); final CanvasGradient grad = ctx.createLinearGradient(x, 0, x, 179); grad.addColorStop(0, "#000000"); //$NON-NLS-1$ grad.addColorStop(0.5, Colors.hsl2html(hsl)); grad.addColorStop(1, "#ffffff"); //$NON-NLS-1$ ctx.setFillStyle(grad); ctx.fillRect(x, 0, 1, 180); } // draw handle if (drawHandle) { ctx.beginPath(); ctx.arc(handleX, handleY, 4, 0, Math.PI * 2, false); ctx.closePath(); ctx.setFillStyle("#ffffff"); //$NON-NLS-1$ ctx.fill(); ctx.beginPath(); ctx.arc(handleX, handleY, 3, 0, Math.PI * 2, false); ctx.closePath(); ctx.setFillStyle("#000000"); //$NON-NLS-1$ ctx.fill(); } }
CircleSprite circle = (CircleSprite) sprite; ctx.beginPath(); ctx.arc(circle.getCenterX(), circle.getCenterY(), circle.getRadius(), 0, 2 * Math.PI); ctx.closePath(); if (sprite.getFill() != null && sprite.getFill() != Color.NONE) {