Skip to content

Icon

Icon Class Documentation

Represents an icon that can be rendered within a GUI using SVG paths.

Constructor

constructor(svgPath: string, width: number, height: number, position: Vec2D, strokeColor: string, fillColor?: string)
ParameterTypeDescription
svgPathstringThe SVG path data for the icon.
widthnumberThe width of the icon.
heightnumberThe height of the icon.
positionVec2DThe initial position of the icon.
strokeColorstringThe color used for the icon’s stroke.
fillColorstring | undefinedThe fill color of the icon. Optional.

Method

render(ctx: CanvasRenderingContext2D): void

Renders the icon onto the specified canvas context.

  • ctx: CanvasRenderingContext2D
    • The canvas rendering context where the icon will be drawn.

Example Usage

import Icon from "./Icon";
import { Vec2D } from "@/types/math";
const icon = new Icon(
"M10 10 H 90 V 90 H 10 L 10 10",
100,
100,
new Vec2D(50, 50),
"#000",
"#fff"
);
icon.render(ctx); // Assuming 'ctx' is your CanvasRenderingContext2D