Skip to content

DrawRect

Draws a rectangle on the canvas.

Usage

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

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

Props

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

Released under the MIT License.