Vector Math & Color Theory

SVG Gradients, Patterns & Paint Servers Glossary (40+ Terms)

SVG Gradients and Vector Paint Servers Studio interface illustrating radial gradients, linear color interpolation, and pattern tiles
Visualizing SVG Paint Servers: Coordinate mapping, radial & linear gradients, and procedural pattern servers.

1. Core Paint Server Containers & Primitives Elements

Paint Server <paint>

The abstract W3C classification for elements (<linearGradient>, <radialGradient>, <pattern>, <meshGradient>) that generate dynamic color, gradients, or graphics referenced via fill="url(#id)" or stroke="url(#id)".

<linearGradient> <linearGradient id="...">

Defines a linear color transition along a straight vector axis connecting two points: (x1, y1) to (x2, y2). Contains one or more <stop> elements defining color offsets.

<linearGradient id="brandGrad" x1="0%" y1="0%" x2="100%" y2="100%">
  <stop offset="0%" stop-color="#C1DD2D" />
  <stop offset="100%" stop-color="#0A0A0A" />
</linearGradient>
<radialGradient> <radialGradient id="...">

Defines a smooth circular or elliptical transition where colors emanate outward from a focal center point to an outer boundary circle or ellipse.

<radialGradient id="sun" cx="50%" cy="50%" r="50%" fx="30%" fy="30%">
  <stop offset="0%" stop-color="#FFF" />
  <stop offset="100%" stop-color="#F59E0B" />
</radialGradient>
<pattern> <pattern id="...">

A container element declaring a reusable tileable vector graphic or image that repeats along the X and Y axes across the interior of any painted element.

<pattern id="dots" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse">
  <circle cx="10" cy="10" r="2" fill="#C1DD2D" />
</pattern>
<meshGradient> SVG 2 Primitive

An advanced SVG 2 specification primitive defining a two-dimensional grid of bicubic Coons patch meshes for photorealistic vector shading and complex color blending.

<defs> <defs>

The definitions container element in SVG. Paint servers declared inside <defs> are not rendered directly on screen; they are held in memory as reusable resource definitions.

<stop> <stop offset="...">

Specifies an individual color milestone along a gradient line. Requires an offset position and color/opacity attributes.

2. Geometry, Endpoints & Focal Coordinates Math & Vectors

x1, y1 (Gradient Start) x1, y1

The starting Cartesian coordinate of the linear gradient vector line. In objectBoundingBox, x1="0%" y1="0%" represents the top-left corner.

x2, y2 (Gradient End) x2, y2

The terminating Cartesian coordinate of the linear gradient vector line. Dictates the angle and direction of the linear color sweep (e.g. x2="100%" y2="0%" creates a horizontal gradient).

cx, cy (Radial Center) cx, cy

Defines the center point of the largest, outermost circle in a <radialGradient>. Defaults to 50%, 50%.

r (Radial Radius) r

Specifies the radius of the outer boundary circle for a radial gradient. Colors reach 100% offset at distance r from the center.

fx, fy (Radial Focal Point) fx, fy

The focal starting point where the 0% color stop originates. Shifting fx and fy away from cx and cy creates asymmetrical specular lighting effects.

fr (Focal Radius) fr

Defines the radius of the inner focal circle where the 0% color stop starts. Enables conical-like donut gradients with hollow centers.

width & height (Pattern Tile) width, height

Specifies the dimensions of a single repeating pattern tile. In patternUnits="userSpaceOnUse", values are expressed in explicit canvas units.

x & y (Pattern Tile Offset) x, y

Establishes the origin alignment offset where the first pattern tile begins repeating across the parent shape.

3. Coordinate Systems & Space Mapping Units

gradientUnits objectBoundingBox | userSpaceOnUse

Specifies the coordinate system for the gradient endpoints (x1, y1, x2, y2) or radial center. Defaults to objectBoundingBox.

patternUnits objectBoundingBox | userSpaceOnUse

Specifies the coordinate system for the pattern container's x, y, width, height tile boundary. Defaults to objectBoundingBox.

patternContentUnits userSpaceOnUse | objectBoundingBox

Specifies the coordinate system for vector paths and graphic primitives drawn inside the pattern tile. Defaults to userSpaceOnUse.

objectBoundingBox Normalized Space [0, 1]

A relative coordinate model where 0.0 corresponds to 0% and 1.0 corresponds to 100% of the target element's bounding box. Gradients automatically scale when the element stretches.

userSpaceOnUse Absolute Canvas Space

Coordinates reference the current SVG document coordinate system directly. Gradients maintain constant absolute scale regardless of individual shape size or aspect ratio.

4. Color Stops, Interpolation & Spread Methods Color Science

offset offset="0%..100%"

A number between 0.0 and 1.0 (or 0% to 100%) indicating where the color stop is situated along the gradient vector.

stop-color CSS Color Value

The color applied at the stop offset. Can be any valid CSS color: hex, rgb, oklch, Display-P3, or currentColor.

stop-opacity stop-opacity="0..1"

The alpha transparency applied to the stop color, ranging from 0.0 (fully transparent) to 1.0 (fully opaque).

spreadMethod="pad" Default Spread

Extends the initial and terminal color stops to fill the remaining area before 0% and after 100% with flat color clamping.

spreadMethod="reflect" Mirroring

Repeats the gradient continuously in alternating reversed directions (0% to 100%, then 100% to 0%), creating mirror-reflection accordion patterns.

spreadMethod="repeat" Cycle Repetition

Repeats the gradient sequence in forward order from 0% to 100% repeatedly across the available surface area.

color-interpolation="linearRGB" Linear Color Math

Interpolates colors in a physically linear color space without gamma curves. Prevents dark muddiness and dirty gray borders between vibrant stop hues.

color-interpolation="sRGB" Perceptual Space

Interpolates colors using the standard non-linear sRGB color space. Matches CSS gradient defaults across standard web browsers.

Display-P3 & OKLCH in Stops Wide Color Gamuts

Modern CSS Color Module Level 4 color spaces supported inside SVG stops. Enables 30% wider color reproduction on modern OLED and Retina screens.

<stop offset="0%" stop-color="oklch(0.85 0.28 142)" />
<stop offset="100%" stop-color="color(display-p3 0.9 0.1 0.2)" />

5. Transformation & Matrix Manipulation Transforms

gradientTransform matrix / rotate / scale

Applies an affine transformation matrix to the gradient coordinate system, allowing rotation angles without recalculating fractional Cartesian coordinates.

<linearGradient id="angled" gradientTransform="rotate(45)">...</linearGradient>
patternTransform Affine Matrix

Applies an affine transformation to the entire pattern tiling matrix. Enables angled diagonal stripes, scaling, and skewing of the tile grid.

Affine Shear in Gradients skewX, skewY

Distorts gradient angles along an oblique plane, frequently employed in isometric vector art and dynamic metallic reflections.

6. Paint Application Rules & Architecture Traps Best Practices

fill="url(#id)" Paint Server Link

The functional URI reference linking an SVG shape's interior fill to a declared paint server ID in the document.

stroke="url(#id)" Stroke Gradient

Applies a paint server directly to the stroked outline path of a vector graphic, creating gradient border lines and neon outline effects.

paint-order fill stroke markers

Controls the order in which fill, stroke, and markers are composited. Setting paint-order: stroke fill renders stroke behind the fill, preserving crisp interior shapes.

fill-rule="nonzero" vs "evenodd" Winding Rules

Algorithms that determine which regions of intersecting vector subpaths are considered 'inside' the shape and thus filled with the paint server.

The SVG ID Collision Trap SPA Bug Risk

Occurs in React, Vue, or Next.js when multiple instances of an icon declare identical id="gradient". Browsers bind to the first matching ID in the DOM. If that element unmounts, all subsequent icons break into blank spaces. Fixed by generating unique IDs with useId().

Shadow DOM Scoping Web Components

Paint servers defined inside a Web Component's Shadow DOM cannot be referenced by outer host elements unless placed inside light DOM <svg> or pierced via CSS variables.

CSS color-mix() in Stops Dynamic Theming

Using modern CSS color-mix() inside stop-color attributes to dynamically derive gradient intermediate steps from text tokens or dark mode variables.

GPU Raster Tile Caching Hardware Acceleration

The browser graphics subsystem rasterizes repeating <pattern> tiles into GPU texture memory once, allowing massive repeating vector backgrounds to scroll at 60 FPS.

Technical Evaluation: objectBoundingBox vs userSpaceOnUse Deep Dive

Architectural Dimension objectBoundingBox (Default) userSpaceOnUse
Coordinate Span Normalized 0.0 to 1.0 (0% to 100%) Absolute SVG viewBox units (pixels/points)
Aspect Ratio Distortion Yes — non-square elements stretch circles into ellipses None — preserves circular radii and strict geometry
Element Resizing Behavior Gradient automatically scales and stretches with target shape Paint remains fixed in canvas space; shape acts as a window
Zero-Width/Height Edge Case Fails (0 divided by 0 collapses paint to black or empty) Renders safely using parent canvas coordinates
Best Fit Use Case UI buttons, responsive badges, card fills, self-contained icons Complex technical diagrams, unified multi-shape charts, tiling

Frequently Asked Questions

What is the key difference between objectBoundingBox and userSpaceOnUse?

objectBoundingBox (default) evaluates coordinates as normalized fractions (0 to 1) relative to the target element's bounding box, automatically scaling with the element. userSpaceOnUse calculates coordinates using the absolute SVG canvas coordinate system, preventing aspect-ratio distortion on non-square shapes.

Why do SVG gradients cause visual bugs or blank fills in Single-Page Apps?

SVG gradients are referenced via ID selectors like fill='url(#grad1)'. When multiple components across routes or lists render identical IDs in the DOM, the browser resolves only the first instance encountered. If that first instance is unmounted or in an off-screen SVG, all other icons referencing that ID collapse into blank transparent fills.

How does spreadMethod govern gradient overflow?

spreadMethod determines how colors behave outside the gradient's x1/y1 and x2/y2 vector span. 'pad' (default) clamps to the first and last stop colors; 'reflect' mirrors the color stops alternately; 'repeat' loops the gradient sequence continuously from 0% to 100%.

What is the difference between color-interpolation='sRGB' and 'linearRGB'?

linearRGB executes color stop interpolation in a physically linear color space where intermediate hues blend naturally without dirty gray or muddy bands. sRGB applies a non-linear gamma curve that can cause dark halos between complementary or high-saturation colors.

Explore 134,701 Clean Vector Icons

Find, customize, and export icons across 28 curated open-source libraries. Zero paywalls, zero attribution requirements.

Search All 134K+ Icons on IconStash →