Closed mrcgrtz closed 2 years ago
An alternative method for creating a squircle on a canvas would be bezierCurveTo()
, see here:
const squircle = (ctx, x, y, size) => {
const hsize = size / 2; // half size
x -= hsize; // reposition in the middle
y -= hsize;
ctx.save();
ctx.translate(x, y);
ctx.beginPath();
ctx.moveTo(hsize, 0);
ctx.bezierCurveTo(0, 0, 0, 0, 0, hsize);
ctx.bezierCurveTo(0, size, 0, size, hsize, size);
ctx.bezierCurveTo(size, size, size, size, size, hsize);
ctx.bezierCurveTo(size, 0, size, 0, hsize, 0);
ctx.closePath();
ctx.restore();
};
bezierCurveTo()
is supported by node-canvas@>=0.0.1
.
Apply a
Path2D
to canvas as in example 3: https://stackoverflow.com/questions/32979585/how-to-squircle-an-app-icon-image-with-just-css#32981019Maybe use https://github.com/google/canvas-5-polyfill