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
| Port | Type | Default |
|---|---|---|
| EnableOff clears this generator's texture, so nothing reaches the canvas. | bool | true |
| XHorizontal centre position in Grafit units, 0 being screen centre. Not clamped. | float | 0 |
| YVertical centre position in Grafit units, 0 being screen centre and positive going up. Not clamped. | float | 0 |
| WidthHorizontal size in Grafit units, where 2 spans the shorter viewport edge. Keep it positive; 0 makes the shape vanish. | float | 0.2 |
| HeightVertical size in Grafit units, where 2 spans the shorter viewport edge. Keep it positive; 0 makes the shape vanish. | float | 0.2 |
| Scale XExtra horizontal multiplier on top of Width, handy for animating a stretch. Not clamped; negative values mirror the shape. | float | 1.0 |
| Scale YExtra vertical multiplier on top of Height. Not clamped; negative values mirror the shape. | float | 1.0 |
| RotationTurns the shape, in degrees clockwise. Any value works — it just keeps rotating. | float | 0 |
| 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. | float | 0 |
| 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. | float | 0 |
| End AngleWhere the visible wedge ends, in degrees clockwise from 12 o'clock. A span of 360 or more shows the whole shape. | float | 360 |
| FillPaints the inside of the shape. Off leaves only the border, if that is on. | bool | true |
| Fill ColorColour of the filled interior, alpha included. | color | — |
| BorderDraws an outline along the shape's edge, including along the sliced ends. | bool | false |
| 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. | float | 0.01 |
| Border ModeWhether the outline sits Inside, Middle or Outside the edge. Anything outside those three draws like Middle. | int | 0 |
| Rounded EndsPuts round caps on the two cut ends of a partial wedge. It does nothing on a full shape. | bool | false |
| AntialiasingSmooths the edges. Off gives hard pixel-stepped edges, which can be what you want for a crisp graphic look. | bool | true |
| ShadowCasts a blurred drop shadow behind the shape. Off skips the shadow passes entirely. | bool | false |
| 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. | float | 0.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. | float | 0.02 |
| Shadow SizeGrows the shadow silhouette before blurring, for a wider halo. Negative values do nothing; around 0…0.1 is the useful band. | float | 0 |
Outputs
| Port | Type |
|---|---|
| Image | image |
| 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
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:
- Base SDF — a rectangle of
Width×Height, multiplied byScale X/Scale Y, with corners rounded byCorner Radius, rotated byRotationaround its center. - Slice mask — if
End Angle − Start Angleis 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. - Fill — when
Fillis on, the interior is covered withFill Color. - Border — when
Borderis on, a stroke ofBorder Widthis drawn on top of the fill, placed perBorder Mode. On partial slices withRounded Endson, 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. - Premultiply — output color is premultiplied (
rgb *= a), the required format for generator textures.
Border Mode values:
| Value | Mode | Stroke placement |
|---|---|---|
| 0 | Inside | Drawn inward from the shape edge (outer stroke edge = shape edge) |
| 1 | Middle | Centered on the edge — half inside, half outside |
| 2 | Outside | Drawn 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 YThe Image output is the full-viewport offscreen texture. When Enable is false, the texture is cleared to transparent.
Parameters in Depth
| Port | Default | Meaning |
|---|---|---|
Enable | true | Master switch. Off clears the output texture to transparent. |
X, Y | 0, 0 | Center position in Grafit units. |
Width, Height | 0.2, 0.2 | Base size in Grafit units (2.0 spans the full shorter viewport edge). |
Scale X, Scale Y | 1.0, 1.0 | Per-axis multipliers on top of Width/Height — handy for animating stretch without touching the base size. |
Rotation | 0 | Rotation in degrees, positive = clockwise, around the rectangle's center. |
Corner Radius | 0 | Corner 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 Angle | 0, 360 | Angular slice span in degrees; 0° at 12 o'clock, clockwise. A span of 360° or more renders the whole rectangle. |
Fill | true | Toggles the solid interior. |
Fill Color | White (1,1,1,1) | RGBA fill color. |
Border | false | Toggles the stroke, drawn on top of the fill. |
Border Color | Black (0,0,0,1) | RGBA stroke color. |
Border Width | 0.01 | Stroke thickness in Grafit units. |
Border Mode | 0 | 0 = Inside, 1 = Middle, 2 = Outside (table above). |
Rounded Ends | false | Rounds the border's endpoints where an angular slice cuts it. Partial slices only; fill cut edges stay straight. |
Antialiasing | true | Smooth SDF edges via the global AA multiplier; off = hard aliased edges. |
Shadow | false | Enables the post-process drop shadow (extra GPU passes). |
Shadow Color | Black (0,0,0,1) | Shadow tint including alpha. |
Shadow Offset X, Shadow Offset Y | 0.02, −0.02 | Shadow displacement in Grafit units. |
Shadow Blur | 0.02 | Gaussian blur radius of the shadow. |
Shadow Size | 0 | Expands 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→Heighton a column of Rectangle nodes for a classic spectrum bar meter. - Progress bar — animate
Width(orScale X) fromTimerorCounterviaRemap; align the bar's leading edge by offsettingXby half the width with aMathnode. - Radial reveal / wipe — drive
End Anglefrom 0 to 360 withRamporLFOto sweep the rectangle in like a clock wipe; addRounded Endson the border for a polished look. - UI card with depth — rounded
Corner Radius, subtleBorder, andShadowwith a small offset and blur makes a floating panel behind Text as Image content. - Pill badge — set
Corner Radiusto half the smaller dimension for a stadium shape; put aText as Imagenode on the Canvas layer above it. - Rotating frame —
Filloff,Borderon,Time→Math→Rotationfor a spinning outlined square marker. - Rectangular mask — feed the
Imageoutput into a Canvas node'sMaskinput to crop any other generator to a (rounded) box.
Tips
- Generators are invisible on their own — connect
Imageto a Canvas node; layers and blend modes are Canvas features. - The
Width/Heightoutputs (base size × scale) are ideal for driving a Canvas or aligning other nodes to the rectangle's footprint; they exclude border overhang (Border Mode1/2) and shadow. - For a perfect pill,
Corner Radius≥ half of the smaller scaled dimension; going beyond that just clamps to a capsule. Rounded Endsonly affects the border at slice cuts; a full 360° rectangle ignores it.- Shadows cost four extra GPU passes — turn
Shadowoff when it is not visible.Shadow Size+Shadow Blurwith 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.