Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Last active October 14, 2018 20:00
Show Gist options
  • Save gskachkov/361705c2d47690a0d1734640360b3620 to your computer and use it in GitHub Desktop.
Save gskachkov/361705c2d47690a0d1734640360b3620 to your computer and use it in GitHub Desktop.
class CircleColor {
static get inputProperties() { return ['--circle-color']; }
paint(ctx, geom, properties) {
// Change the fill color.
const color = properties.get('--circle-color').toString();
ctx.fillStyle = color;
// Determine the center point and radius.
const x = geom.width / 2;
const y = geom.height / 2;
const radius = Math.min(x, y);
// Draw the circle
ctx.beginPath();
ctx.arc(x, y, radius, 0, 2 * Math.PI);
ctx.fill();
}
}
registerPaint('circleColor', CircleColor);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment