Quick Start with @idraw/renderer
mainTo use the renderer, instantiate a new Renderer with a configuration object, then call the .render() method passing a canvas element and an array of elements to draw.
Configuration Options:
width: The width of the rendering area.height: The height of the rendering area.contextWidth: The width of the drawing context.contextHeight: The height of the drawing context.devicePixelRatio: The pixel ratio for high-DPI displays.
import Renderer from '@idraw/renderer';
const renderer = new Renderer({
width: 600,
height: 400,
contextWidth: 600,
contextHeight: 400,
devicePixelRatio: 1,
});
const canvas = document.querySelector('canvas');
renderer.render(canvas, {
elements: [
{
name: "rect-001",
x: 10,
y: 10,
w: 200,
h: 100,
type: "rect",
detail: {
bgColor: "#f0f0f0",
borderRadius: 20,
borderWidth: 10,
borderColor: "#bd0b64",
},
},
]
});