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();
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(); }
protected void onComplete() { super.onComplete(); context.closePath(); context.clearRect(0, 0, centerX*2, centerY*2);
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(); } }
context.lineTo(child.getIntAttribute("to_x"), child.getIntAttribute("to_y")); context.closePath(); context.stroke();
private void drawGradient() { final Context2d ctx = canvas.getContext2d(); // draw gradient ctx.setFillStyle("#ffffff"); //$NON-NLS-1$ ctx.fillRect(0, 0, 26, 180); final Hsl hsl = new Hsl(0, 100, 50); for (int y = 0; y <= 179; y++) { hsl.setH(y * 2); ctx.setFillStyle(Colors.hsl2html(hsl)); ctx.fillRect(3, y, 20, 1); } // draw handle if (handleY >= 0) { ctx.setFillStyle("#000000"); //$NON-NLS-1$ ctx.beginPath(); ctx.moveTo(3, handleY); ctx.lineTo(0, handleY - 3); ctx.lineTo(0, handleY + 3); ctx.closePath(); ctx.fill(); ctx.moveTo(23, handleY); ctx.lineTo(26, handleY - 3); ctx.lineTo(26, handleY + 3); ctx.closePath(); ctx.fill(); } }
ctx.closePath(); break;
ctx.closePath(); break;
ctx.closePath(); break;
@Override public void paint(Canvas canvas, Matrix matrix) { if (Geometry.POLYGON.equals(geometry.getGeometryType())) { canvas.getContext2d().save(); canvas.getContext2d().setFillStyle(fillStyle); canvas.getContext2d().setStrokeStyle(strokeStyle); canvas.getContext2d().setLineWidth(strokeWidthPixels / matrix.getXx()); canvas.getContext2d().beginPath(); for (Geometry ring : geometry.getGeometries()) { Coordinate[] coords = ring.getCoordinates(); canvas.getContext2d().moveTo(coords[0].getX(), coords[0].getY()); for (int i = 1; i < coords.length - 1; i++) { canvas.getContext2d().lineTo(coords[i].getX(), coords[i].getY()); } } canvas.getContext2d().closePath(); canvas.getContext2d().fill(); canvas.getContext2d().stroke(); canvas.getContext2d().restore(); } }
@Override public void paint(Canvas canvas, Matrix matrix) { if (Geometry.POLYGON.equals(geometry.getGeometryType())) { canvas.getContext2d().save(); canvas.getContext2d().setFillStyle(fillStyle); canvas.getContext2d().setStrokeStyle(strokeStyle); canvas.getContext2d().setLineWidth(strokeWidthPixels / matrix.getXx()); canvas.getContext2d().beginPath(); for (Geometry ring : geometry.getGeometries()) { Coordinate[] coords = ring.getCoordinates(); canvas.getContext2d().moveTo(coords[0].getX(), coords[0].getY()); for (int i = 1; i < coords.length - 1; i++) { canvas.getContext2d().lineTo(coords[i].getX(), coords[i].getY()); } } canvas.getContext2d().closePath(); canvas.getContext2d().fill(); canvas.getContext2d().stroke(); canvas.getContext2d().restore(); } }
ctx.beginPath(); ctx.rect(clip.getX(), clip.getY(), clip.getWidth(), clip.getHeight()); ctx.closePath(); ctx.beginPath(); ctx.arc(circle.getCenterX(), circle.getCenterY(), circle.getRadius(), 0, 2 * Math.PI); ctx.closePath(); if (sprite.getFill() != null && sprite.getFill() != Color.NONE) { ctx.setGlobalAlpha(Double.isNaN(sprite.getFillOpacity()) ? opacity : opacity * sprite.getFillOpacity());
quadraticPoint.setY(currentPoint.getY()); ctx.closePath(); } else { assert cmd instanceof EllipticalArc