Region

Regions define areas where filters or effects are applied. They can be used with filters to create localized effects like selective blur, color grading in specific areas, or masked transitions.

Usage

Regions are specified in the region property of a filterAgent or effect configuration. They support various geometric shapes and gradient masks.

PropTypeRequiredExampleValue RangeDescription
typestringtrue-circle | ellipse | rectangle | roundedRect | triangle | polygon | star | ring | heart | linear | radialThe shape type of the region.
enabledbooleanfalse--Whether the region mask is active.
invertbooleanfalse--If true, the effect is applied outside the region instead of inside.
centerXnumberfalse--The horizontal center position of the region, normalized (0-1, where 0.5 is center).
centerYnumberfalse--The vertical center position of the region, normalized (0-1, where 0.5 is center).
widthnumberfalse--The width of the region, normalized (0-1).
heightnumberfalse--The height of the region, normalized (0-1).
rotationnumberfalse--The rotation angle of the region, in radians.
feathernumberfalse--The edge softness/blur amount, normalized (0-1). Higher values create softer edges.

Shape-Specific Parameters

Rectangle (rectangle, roundedRect)

  • cornerRadius: Corner radius for rounded rectangles (0-1)

Star (star)

  • starPoints: Number of star points (default: 5)
  • starInnerRadius: Inner radius ratio (0-1, default: 0.5)

Ring (ring)

  • ringInnerRadius: Inner radius of the ring (0-1)

Gradient (linear, radial)

  • linearAngle: Angle for linear gradients, in radians (0 = horizontal, π/2 = vertical)
  • gradientStart: Start position of gradient transition (0-1)
  • gradientEnd: End position of gradient transition (0-1)

Examples

Circular Region with Feathering

Apply a blur filter only to a circular area in the center:

circularRegion.json
1{ 2"filterAgent": { 3 "type": "Basic Blur", 4 "options": [{ "key": "radius", "value": 10 }], 5 "region": { 6 "type": "circle", 7 "enabled": true, 8 "invert": false, 9 "centerX": 0.5, 10 "centerY": 0.5, 11 "width": 0.3, 12 "height": 0.3, 13 "feather": 0.1 14 } 15} 16} 17

Inverted Rectangle Region

Apply a color filter everywhere except a rectangular area:

invertedRectangle.json
1{ 2"filterAgent": { 3 "type": "Sepia", 4 "region": { 5 "type": "rectangle", 6 "enabled": true, 7 "invert": true, 8 "centerX": 0.5, 9 "centerY": 0.5, 10 "width": 0.6, 11 "height": 0.4, 12 "feather": 0.05 13 } 14} 15} 16

Linear Gradient Region

Apply a filter with a gradient transition from top to bottom:

linearGradient.json
1{ 2"filterAgent": { 3 "type": "Bloom", 4 "options": [{ "key": "strength", "value": 1.5 }], 5 "region": { 6 "type": "linear", 7 "enabled": true, 8 "linearAngle": 1.5708, 9 "gradientStart": 0.3, 10 "gradientEnd": 0.7, 11 "feather": 0 12 } 13} 14} 15

Star-Shaped Region

Create a star-shaped mask:

starRegion.json
1{ 2"filterAgent": { 3 "type": "Glow", 4 "region": { 5 "type": "star", 6 "enabled": true, 7 "centerX": 0.5, 8 "centerY": 0.5, 9 "width": 0.4, 10 "height": 0.4, 11 "starPoints": 5, 12 "starInnerRadius": 0.4, 13 "rotation": 0, 14 "feather": 0.05 15 } 16} 17} 18

Rounded Rectangle with Rotation

roundedRect.json
1{ 2"filterAgent": { 3 "type": "Pixelate", 4 "options": [{ "key": "size", "value": 16 }], 5 "region": { 6 "type": "roundedRect", 7 "enabled": true, 8 "centerX": 0.5, 9 "centerY": 0.5, 10 "width": 0.5, 11 "height": 0.3, 12 "cornerRadius": 0.1, 13 "rotation": 0.785398, 14 "feather": 0.02 15 } 16} 17} 18

Important Notes

Coordinate System

  • Normalized Coordinates: All position and size values (centerX, centerY, width, height) are normalized to the range 0-1
    • 0.5 = center of the canvas/element
    • 0 = left/top edge
    • 1 = right/bottom edge
  • Rotation Units: Rotation values are in radians, not degrees
    • To convert: radians = degrees × π / 180
    • Examples: 90° = 1.5708 rad, 180° = 3.14159 rad, 45° = 0.785398 rad

Feathering

  • Controls the softness of the region's edges
  • 0 = hard edge (sharp transition)
  • Higher values create softer, more gradual transitions
  • Recommended range: 0.01 to 0.2 for most effects

Performance

  • Complex shapes (star, polygon with many points) may impact rendering performance
  • Gradient regions (linear, radial) are computationally efficient
  • Feathering has minimal performance impact

Region vs Mask

  • Region (filterAgent.region): Controls where a filter effect is applied
  • Mask (maskData): Crops the element itself (node-level clipping)
  • Regions can be inverted; masks cannot
  • Regions support gradients and feathering; masks are always hard-edged

Supported Shape Types

ShapeDescriptionSpecial Parameters
circlePerfect circlewidth sets diameter
ellipseElliptical shapewidth and height independent
rectangleRectangular area-
roundedRectRectangle with rounded cornerscornerRadius
triangleTriangular shape-
polygonMulti-sided polygonpoints (vertex count)
starStar shapestarPoints, starInnerRadius
ringDonut/ring shaperingInnerRadius
heartHeart shape-
linearLinear gradient masklinearAngle, gradientStart/End
radialRadial gradient maskgradientStart/End