@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 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 clipRect(float x, float y, float width, float height) { ctx.beginPath(); ctx.rect(x, y, width, height); ctx.clip(); 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 clipRect(float x, float y, float width, float height) { ctx.beginPath(); ctx.rect(x, y, width, height); ctx.clip(); return this; }
@Override public Canvas clipRect(float x, float y, float width, float height) { ctx.beginPath(); ctx.rect(x, y, width, height); ctx.clip(); 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 drawPoint(float x, float y) { ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x, y); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas drawPoint(float x, float y) { ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x, y); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas drawPoint(float x, float y) { ctx.beginPath(); ctx.moveTo(x, y); ctx.lineTo(x, y); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas drawLine(float x0, float y0, float x1, float y1) { ctx.beginPath(); ctx.moveTo(x0, y0); ctx.lineTo(x1, y1); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas drawLine(float x0, float y0, float x1, float y1) { ctx.beginPath(); ctx.moveTo(x0, y0); ctx.lineTo(x1, y1); ctx.stroke(); isDirty = true; return this; }
@Override public Canvas drawLine(float x0, float y0, float x1, float y1) { ctx.beginPath(); ctx.moveTo(x0, y0); ctx.lineTo(x1, y1); ctx.stroke(); 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; ctx.beginPath(); ctx.moveTo(x, midy); ctx.arcTo(x, y, midx, y, radius); ctx.arcTo(maxx, y, maxx, midy, radius); ctx.arcTo(maxx, maxy, midx, maxy, radius); ctx.arcTo(x, maxy, x, midy, radius); ctx.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; ctx.beginPath(); ctx.moveTo(x, midy); ctx.arcTo(x, y, midx, y, radius); ctx.arcTo(maxx, y, maxx, midy, radius); ctx.arcTo(maxx, maxy, midx, maxy, radius); ctx.arcTo(x, maxy, x, midy, radius); ctx.closePath(); }
Canvas canvas = Canvas.createIfSupported(); Context2d context1 = canvas.getContext2d(); context1.beginPath(); context1.moveTo(25,0); context1.lineTo(0,20); context1.lineTo(25,40); context1.lineTo(25,0); context1.fill(); context1.closePath();