Generator node

Rectangle

Draws a rectangle — sharp or rounded, filled or outlined, whole or cut into an angular slice — as a GPU texture. Like Circle 2D it is rendered from a signed distance field, so corners and edges stay crisp at any resolution, and a post-process drop shadow is available. It is the workhorse for panels, bars, cards, pills, frames, and radial-reveal effects; composite the result with a Canvas node.

Inputs

PortTypeDefault
EnableOff clears this generator's texture, so nothing reaches the canvas.booltrue
XHorizontal centre position in Grafit units, 0 being screen centre. Not clamped.float0
YVertical centre position in Grafit units, 0 being screen centre and positive going up. Not clamped.float0
WidthHorizontal size in Grafit units, where 2 spans the shorter viewport edge. Keep it positive; 0 makes the shape vanish.float0.2
HeightVertical size in Grafit units, where 2 spans the shorter viewport edge. Keep it positive; 0 makes the shape vanish.float0.2
Scale XExtra horizontal multiplier on top of Width, handy for animating a stretch. Not clamped; negative values mirror the shape.float1.0
Scale YExtra vertical multiplier on top of Height. Not clamped; negative values mirror the shape.float1.0
RotationTurns the shape, in degrees clockwise. Any value works — it just keeps rotating.float0
Corner RadiusRounds the corners, in Grafit units. Not clamped: up to half the shorter side it rounds into a pill, beyond that the shape starts swelling outward.float0
Start AngleWhere the visible wedge begins, in degrees clockwise from 12 o'clock. Together with End Angle it slices the shape like a pie chart.float0
End AngleWhere the visible wedge ends, in degrees clockwise from 12 o'clock. A span of 360 or more shows the whole shape.float360
FillPaints the inside of the shape. Off leaves only the border, if that is on.booltrue
Fill ColorColour of the filled interior, alpha included.color—
BorderDraws an outline along the shape's edge, including along the sliced ends.boolfalse
Border ColorColour of the outline, alpha included.color—
Border WidthThickness of the outline in Grafit units. Not clamped; around 0.002…0.05 stays a line rather than a second shape.float0.01
Border ModeWhether the outline sits Inside, Middle or Outside the edge. Anything outside those three draws like Middle.int0
Rounded EndsPuts round caps on the two cut ends of a partial wedge. It does nothing on a full shape.boolfalse
AntialiasingSmooths the edges. Off gives hard pixel-stepped edges, which can be what you want for a crisp graphic look.booltrue
ShadowCasts a blurred drop shadow behind the shape. Off skips the shadow passes entirely.boolfalse
Shadow ColorColour of the drop shadow, alpha included — lower the alpha for a softer, subtler cast.color—
Shadow Offset XHow far the shadow is pushed sideways, in Grafit units. Not clamped; small values around ±0.05 read as depth.float0.02
Shadow Offset YHow far the shadow is pushed vertically, in Grafit units, positive going up. Negative drops it below the shape.float-0.02
Shadow BlurSoftness of the shadow, in Grafit units. Not clamped, and the blur kernel grows with it — past about 0.2 it gets expensive.float0.02
Shadow SizeGrows the shadow silhouette before blurring, for a wider halo. Negative values do nothing; around 0…0.1 is the useful band.float0

Outputs

PortType
Imageimage
WidthHorizontal size in Grafit units, where 2 spans the shorter viewport edge. Keep it positive; 0 makes the shape vanish.float
HeightVertical size in Grafit units, where 2 spans the shorter viewport edge. Keep it positive; 0 makes the shape vanish.float

Live Preview

Interactive — Corner radius, pie slice and border live

How It Works

Each frame, Rectangle renders a fullscreen pass into its own offscreen Metal texture. The fragment shader evaluates a rounded-rectangle signed distance field (SDF) per pixel and converts the distance to the edge into smooth coverage. Because the shape is analytic, there is no polygon tessellation and no resolution dependence.

Coordinates follow the Grafit standard: origin (0,0) at the viewport center, shorter viewport edge mapped to [-1, +1]. X, Y, Width, Height, Corner Radius, and Border Width are all in Grafit units. Positive Rotation is clockwise, in degrees.

The shape is built in this order:

  1. Base SDF — a rectangle of Width × Height, multiplied by Scale X / Scale Y, with corners rounded by Corner Radius, rotated by Rotation around its center.
  2. Slice mask — if End Angle − Start Angle is less than 360°, an angular mask (the same one Circle 2D uses for arcs) cuts a pie-style slice out of the rectangle. Angles start at 12 o'clock (0°) and increase clockwise, rotating together with the shape.
  3. Fill — when Fill is on, the interior is covered with Fill Color.
  4. Border — when Border is on, a stroke of Border Width is drawn on top of the fill, placed per Border Mode. On partial slices with Rounded Ends on, circular caps (radius = half the border width) are placed exactly where the slice cut crosses the rectangle's border — the cap centers are found by ray-marching the SDF, so they sit correctly even on rounded corners.
  5. Premultiply — output color is premultiplied (rgb *= a), the required format for generator textures.

Border Mode values:

ValueModeStroke placement
0InsideDrawn inward from the shape edge (outer stroke edge = shape edge)
1MiddleCentered on the edge — half inside, half outside
2OutsideDrawn outward from the edge (inner stroke edge = shape edge)

Antialiasing uses the global AA multiplier; the node's Antialiasing toggle just enables or disables it for this shape. The drop shadow is a GPU post-process (geometry extract → separable Gaussian blur → tinted composite underneath the shape), not part of the SDF — and unlike Circle 2D, Rectangle's Shadow Size is functional, expanding the shadow silhouette beyond the shape before blurring.

The Width and Height outputs report the shape's bounding size in Grafit units, not the texture size:

Width  = Width × Scale X
Height = Height × Scale Y

The Image output is the full-viewport offscreen texture. When Enable is false, the texture is cleared to transparent.

Parameters in Depth

PortDefaultMeaning
EnabletrueMaster switch. Off clears the output texture to transparent.
X, Y0, 0Center position in Grafit units.
Width, Height0.2, 0.2Base size in Grafit units (2.0 spans the full shorter viewport edge).
Scale X, Scale Y1.0, 1.0Per-axis multipliers on top of Width/Height — handy for animating stretch without touching the base size.
Rotation0Rotation in degrees, positive = clockwise, around the rectangle's center.
Corner Radius0Corner rounding in Grafit units. 0 = sharp; half of the smaller scaled dimension = a pill/stadium shape. Note it is not multiplied by Scale X/Y.
Start Angle, End Angle0, 360Angular slice span in degrees; 0° at 12 o'clock, clockwise. A span of 360° or more renders the whole rectangle.
FilltrueToggles the solid interior.
Fill ColorWhite (1,1,1,1)RGBA fill color.
BorderfalseToggles the stroke, drawn on top of the fill.
Border ColorBlack (0,0,0,1)RGBA stroke color.
Border Width0.01Stroke thickness in Grafit units.
Border Mode00 = Inside, 1 = Middle, 2 = Outside (table above).
Rounded EndsfalseRounds the border's endpoints where an angular slice cuts it. Partial slices only; fill cut edges stay straight.
AntialiasingtrueSmooth SDF edges via the global AA multiplier; off = hard aliased edges.
ShadowfalseEnables the post-process drop shadow (extra GPU passes).
Shadow ColorBlack (0,0,0,1)Shadow tint including alpha.
Shadow Offset X, Shadow Offset Y0.02, −0.02Shadow displacement in Grafit units.
Shadow Blur0.02Gaussian blur radius of the shadow.
Shadow Size0Expands the shadow silhouette beyond the shape before blurring — larger values read as a bigger, softer halo.

Interactions: the SDF uses Width × Scale X and Height × Scale Y as the true size, so scaling and resizing are visually equivalent — but only Width/Height show up as the natural "size" while the scales are convenient animation targets. Corner Radius stays constant under scaling, so a stretched rectangle keeps its corner rounding.

Use Cases

  • Audio level bars — Audio FFT → Array Get → Remap → Height on a column of Rectangle nodes for a classic spectrum bar meter.
  • Progress bar — animate Width (or Scale X) from Timer or Counter via Remap; align the bar's leading edge by offsetting X by half the width with a Math node.
  • Radial reveal / wipe — drive End Angle from 0 to 360 with Ramp or LFO to sweep the rectangle in like a clock wipe; add Rounded Ends on the border for a polished look.
  • UI card with depth — rounded Corner Radius, subtle Border, and Shadow with a small offset and blur makes a floating panel behind Text as Image content.
  • Pill badge — set Corner Radius to half the smaller dimension for a stadium shape; put a Text as Image node on the Canvas layer above it.
  • Rotating frame — Fill off, Border on, Time → Math → Rotation for a spinning outlined square marker.
  • Rectangular mask — feed the Image output into a Canvas node's Mask input to crop any other generator to a (rounded) box.

Tips

  • Generators are invisible on their own — connect Image to a Canvas node; layers and blend modes are Canvas features.
  • The Width/Height outputs (base size × scale) are ideal for driving a Canvas or aligning other nodes to the rectangle's footprint; they exclude border overhang (Border Mode 1/2) and shadow.
  • For a perfect pill, Corner Radius ≥ half of the smaller scaled dimension; going beyond that just clamps to a capsule.
  • Rounded Ends only affects the border at slice cuts; a full 360° rectangle ignores it.
  • Shadows cost four extra GPU passes — turn Shadow off when it is not visible. Shadow Size + Shadow Blur with zero offset makes a soft ambient glow.
  • Antialiasing quality is the global AA multiplier; the per-node toggle only opts this shape in or out.
  • Related nodes: Circle 2D (same feature set for circles/arcs), Gradient (gradient fills to mask with this shape), Replicator (grids of rectangles without duplicating nodes).

Open Rectangle in the interactive catalog →

Rectangle is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More Generator nodes