On an <canvas>, createRadialGradient(x0, y0, r0, x1, y1, r1) blends colors between two circles. It returns a CanvasGradient. Add stops with addColorStop(), then assign it to fillStyle or strokeStyle before you draw.
Gradient coordinates are global (canvas space), not local to the shape. Same center with r0 = 0 makes a soft circular glow; offset centers make a spotlight. For straight blends, see linear gradients.
Baseline · Widely available.
createRadialGradient and addColorStop are stable Canvas 2D features across modern browsers since about July 2015.
Most radial bugs come from global coordinates, bad radii, or invalid stop values.
coords
Coordinates are global
Circles are not relative to the shape. If the box moves, update the circle centers (or transform the context).
radius
Radii must be ≥ 0
Negative radius → IndexSizeError. Non-finite values → NotSupportedError. Zero is fine (a point).
stops
Offset must be 0–1
Values outside that range throw IndexSizeError. Invalid colors throw SyntaxError.
clip
Shape vs gradient size
If r1 is smaller than your shape, the outer color fills the rest. Match radii to the area you want to cover.
Compatibility
Browser Support
createRadialGradient and addColorStop are part of the Canvas 2D API in every modern browser.
✓ Baseline · Widely available
Radial gradients
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support radial CanvasGradient fills and strokes. Internet Explorer 9+ also supports them.
98%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetAll modern
Full support
Internet Explorer9+
Supported
createRadialGradientWidely supported
Bottom line: Safe for production glows, spotlights, and soft fades on Canvas 2D everywhere modern browsers run.
Space: circle centers and radii are global to the canvas.
One line: two circles → add stops → assign style → draw.
UA style
Default CSS Settings
Gradients are a Canvas API concern. The <canvas> element still uses typical user-agent CSS:
default.css
canvas {
display: inline;
}
Set bitmap size with HTML width/height. CSS-only sizing scales the bitmap and can soften gradient edges.
Frequently Asked Questions
Call createRadialGradient(x0, y0, r0, x1, y1, r1), add color stops with addColorStop(offset, color), assign the gradient to fillStyle or strokeStyle, then draw.
The first circle (x0, y0, r0) is where the gradient starts; the second (x1, y1, r1) is where it ends. Same center + r0 = 0 gives a classic circular glow. Offset centers create a spotlight.
Gradient coordinates are global (canvas space), not relative to the shape. Align the circles with where you draw, or transform the context first.
Zero is allowed (a point). Negative radii throw IndexSizeError. Non-finite numbers throw NotSupportedError.
Yes. Set strokeStyle to the CanvasGradient, then stroke() a path or use strokeRect / strokeText.
Linear blends along a line (createLinearGradient). Radial blends between two circles (createRadialGradient). Both use addColorStop and fillStyle/strokeStyle the same way.