@Override public Canvas moveTo(int x, int y) { addOperation(() -> context2d.moveTo(x, y)); 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; }
@Override public void draw( Context2d ctx, double x, double y, double radius ) { ctx.beginPath(); ctx.moveTo( x + radius, y + radius ); ctx.lineTo( x, y ); ctx.lineTo( x - radius, y + radius ); ctx.stroke(); } }
@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 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(); }
context.moveTo(centerX, centerY); context.lineTo( centerX + 2 * centerX * Math.cos((progress * Math.PI * 2)-Math.PI/2),
context.setStrokeStyle("black"); context.beginPath(); context.moveTo(child.getIntAttribute("from_x"), child.getIntAttribute("from_y")); context.lineTo(child.getIntAttribute("to_x"),
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(); } }
x = list.get(i++); y = list.get(i++); ctx.moveTo(x, y); break;
x = list.get(i++); y = list.get(i++); ctx.moveTo(x, y); 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(); } }