Last active
October 14, 2018 20:00
-
-
Save gskachkov/361705c2d47690a0d1734640360b3620 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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