API Index
Charming offers a set of utilities for working with SVG and Canvas, which can be used either together or independently.
Charming DOM
Create and manipulate DOM elements.
- cm.svg — SVG via tagged template literal.
- cm.html — HTML via tagged template literal.
- cm.attr — get, set, or remove attributes (including styles and events) on a node.
Charming Canvas
Set up a 2D canvas and draw shapes.
- cm.context2d — create a 2D canvas rendering context (size, DPR, optional container).
- cm.cssFont — build a CSS
fontshorthand string (canvas, DOM, or D3). - cm.strokeLine — stroke a line between two points.
- cm.fillCircle — fill a circle.
- cm.strokeCircle — stroke a circle.
- cm.strokeEllipse — stroke an axis-aligned ellipse.
- cm.fillEllipse — fill an axis-aligned ellipse.
Charming Path
Build SVG path strings for common shapes.
- cm.pathLine — open segment
M…L… - cm.pathCircle — closed circle.
- cm.pathRect — closed rectangle.
- cm.pathEllipse — closed axis-aligned ellipse.
- cm.pathPolygon — closed path through
[x, y]points.