a:gradFill (Gradient Fill)

Specifies a gradient fill with color stops that smoothly transitions between colors across a shape, line, or text.

Parent elements

Child elements

Description

\:gradFill\ is the DrawingML gradient fill element that applies a color gradient to shapes, lines, text bodies, and grouped shapes. It is defined in ECMA-376 Part 1 §20.1.4.8.

Gradient fills enable smooth color transitions from one color to another, creating sophisticated visual effects. The gradient can flow in two modes:

  • Linear Gradient (\:lin): Colors transition along a straight path with optional rotation and scaling
  • Path Gradient (\:path): Colors radiate from a rectangular or elliptical path (like a sun radiating outward)

Key features:

  • Multiple color stops define the gradient spectrum, each with a position (0–100000 representing 0–100%)
  • Linear gradients use angle-based direction (0–21600000 in 60,000ths of a degree)
  • Path gradients define a focus rectangle for radial effects
  • Optional flipping (x, y, or both axes) and rotation with shape
  • Gradient fills enhance modern, professional-looking designs
  • Used extensively in charts, data visualizations, and presentation graphics

Gradient fills are more computationally intensive than solid fills but provide better visual hierarchy and polish.

Attributes

Attribute Type Range/Values Default Description
\ lip\ \ST_ShapeFlipValues\ none, x, y, xy none Flip the gradient direction along specified axes.
\        
otWithShape\ \xsd:boolean\ 0, 1 (true, false) 1 If true, gradient rotates when the shape is rotated.
\        
oFill\ \xsd:boolean\ 0, 1 0 If true, no fill is applied (overrides gradient).
\useShapeAnchor\ \xsd:boolean\ 0, 1 0 If true, use shape anchor point; if false, use shape bounds.

Content Model

\:gradFill\ contains:

  1. Exactly one \:gsLst\ (gradient stops list) – defines colors and positions
  2. Exactly one of: \:lin\ (linear gradient) OR \:path\ (path/radial gradient)

Child Elements Table

Element Occurrence Purpose
\:gsLst\ 1 Gradient stops list with color definitions.
\:lin\ 0–1 Linear gradient properties for directional color flow.
\:path\ 0–1 Path gradient properties for radial fill effects.

Examples

Linear Gradient (Blue to White)

<a:spPr>
  <a:gradFill rotWithShape=\"1\">
    <a:gsLst>
      <a:gs pos=\"0\">
        <a:srgbClr val=\"0070C0\"/>
      </a:gs>
      <a:gs pos=\"100000\">
        <a:srgbClr val=\"FFFFFF\"/>
      </a:gs>
    </a:gsLst>
    <a:lin ang=\"0\" scaled=\"1\"/>
  </a:gradFill>
</a:spPr>

Multi-Color Gradient (Red → Yellow → Green)

<a:gradFill>
  <a:gsLst>
    <a:gs pos=\"0\">
      <a:srgbClr val=\"FF0000\"/>
    </a:gs>
    <a:gs pos=\"50000\">
      <a:srgbClr val=\"FFFF00\"/>
    </a:gs>
    <a:gs pos=\"100000\">
      <a:srgbClr val=\"00B050\"/>
    </a:gs>
  </a:gsLst>
  <a:lin ang=\"2700000\" scaled=\"1\"/>
</a:gradFill>

Radial Gradient (Center-radiating)

<a:gradFill>
  <a:gsLst>
    <a:gs pos=\"0\">
      <a:srgbClr val=\"FFFFFF\"/>
    </a:gs>
    <a:gs pos=\"100000\">
      <a:srgbClr val=\"000000\"/>
    </a:gs>
  </a:gsLst>
  <a:path path=\"circle\">
    <a:fillToRect l=\"50000\" t=\"50000\" r=\"50000\" b=\"50000\"/>
  </a:path>
</a:gradFill>

Gradient with Transparency

<a:gradFill flip=\"none\" rotWithShape=\"0\">
  <a:gsLst>
    <a:gs pos=\"0\">
      <a:srgbClr val=\"4472C4\">
        <a:alpha val=\"100000\"/>
      </a:srgbClr>
    </a:gs>
    <a:gs pos=\"100000\">
      <a:srgbClr val=\"4472C4\">
        <a:alpha val=\"20000\"/>
      </a:srgbClr>
    </a:gs>
  </a:gsLst>
  <a:lin ang=\"5400000\" scaled=\"1\"/>
</a:gradFill>

Gradient with Scheme Colors (Theme-aware)

<a:gradFill rotWithShape=\"1\">
  <a:gsLst>
    <a:gs pos=\"0\">
      <a:schemeClr val=\"accent1\">
        <a:tint val=\"50000\"/>
      </a:schemeClr>
    </a:gs>
    <a:gs pos=\"100000\">
      <a:schemeClr val=\"accent1\">
        <a:shade val=\"50000\"/>
      </a:schemeClr>
    </a:gs>
  </a:gsLst>
  <a:lin ang=\"2700000\" scaled=\"1\"/>
</a:gradFill>

Reference Tables

Linear Gradient Angles

Angle Degrees Direction Use Case
0 0° Right (→) Left-to-right fade
2700000 90° Down (↓) Top-to-bottom fade
5400000 180° Left (←) Right-to-left fade
8100000 270° Up (↑) Bottom-to-top fade

Gradient Stop Positions

Position Percentage Meaning
0 0% Start color
25000 25% Quarter point
50000 50% Midpoint
75000 75% Three-quarter point
100000 100% End color

Notes

Element Relationships

  • Parents: Shape properties (\:spPr), group properties (\:grpSpPr), line properties (\:ln), text body (\:txBody)
  • Fill Priority: Only one fill type allowed per container; first defined fill is applied
  • Children: Must contain gradient stops (\:gsLst) and exactly one gradient direction (\:lin\ or \:path)

Implementation Details

  • Gradient Stops: Position values must be in ascending order (0–100000); minimum 2 stops required
  • Color Modifiers: Stop colors support tint, shade, alpha, lumMod, lumOff for blending effects
  • Linear vs Radial: Linear gradients render faster; path gradients enable spotlight/halo effects
  • Rotation:
    otWithShape="1"\ maintains gradient angle relative to shape orientation
  • Theme Integration: Scheme colors enable automatic theme switching; RGB colors are static
  • Performance: Gradients consume more resources than solid fills; use judiciously in large documents
  • Compatibility: Cross-Office rendering supported; some exotic gradient combinations may degrade in older clients