UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

13 lines (12 loc) 516 B
import { render } from "./render"; export function renderSVG(icon, ctx, rect) { render(ctx, (isolatedCtx) => { const iconPath = new Path2D(icon.path); const coefX = icon.width / icon.iniatialWidth; const coefY = icon.height / icon.initialHeight; // MoveTo position isolatedCtx.translate(rect.x + rect.width / 2 - icon.width / 2, rect.y + rect.height / 2 - icon.height / 2); isolatedCtx.scale(coefX, coefY); isolatedCtx.fill(iconPath, "evenodd"); }); }