How to style canvas elements with CSS
问题 I have a lot of figures and elements drawn in the a HTML canvas. All of them have different colors, strokes, etc. I really don't like that all these values are wandering in my JS code as some styles are in the CSS and some are in the code. Does somebody know a good way to define the styles in CSS and read the styles when actually rendering the objects? Here is some example of what I need to do: context.beginPath(); context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false); context