Skip to content

DrawRect

Draws a rectangle on the canvas.

Usage

tsx
import { Canvas, DrawRect } from 'flexium-canvas/dom';

<Canvas width={200} height={200}>
  <DrawRect
    x={10}
    y={10}
    width={100}
    height={50}
    fill="green"
    stroke="black"
    strokeWidth={2}
  />
</Canvas>

Props

PropTypeDescription
xnumber | StateValue<number>The x-coordinate of the top-left corner.
ynumber | StateValue<number>The y-coordinate of the top-left corner.
widthnumber | StateValue<number>The width of the rectangle.
heightnumber | StateValue<number>The height of the rectangle.
fillstring | StateValue<string>The fill color.
strokestring | StateValue<string>The stroke color.
strokeWidthnumber | StateValue<number>The width of the stroke.
opacitynumber | StateValue<number>Opacity (0 to 1).

Released under the MIT License.