OPF

Search docs

Loading documentation…
    OpenPresentation/opf
    Browse docs
    On this page
    View source

    Gradient

    A gradient fill: the background gradient object extended with 'type'. DrawingML a:gradFill: a:lin for linear, a:path circle, rect or shape for the others. The gradient rotates with the shape.

    Metadata

    Definition
    #/$defs/Gradient
    Form
    object
    Source
    spec/schemas/opf.schema.json

    Field index

    FieldTypeReq.Description
    typeenum—linear runs along 'angle'; radial spreads from the center as a circle, rectangle as a rectangle and shape along the shape's own outline (a:path circle, rect, shape). Default linear.
    type · Allowed values
    "linear""radial""rectangle""shape"
    anglenumber—Linear gradients only: angle in degrees (0 = left to right, 90 = top to bottom). Default 90.
    stopsarray<object>yesOrdered color stops; at least two. A radial, rectangle or shape gradient runs from the center (position 0) to the outline (position 1).

    type

    typeenumrequirednodefault—

    linear runs along 'angle'; radial spreads from the center as a circle, rectangle as a rectangle and shape along the shape's own outline (a:path circle, rect, shape). Default linear.

    type · Allowed values
    "linear""radial""rectangle""shape"
    type.json
    {
      "type": "linear"
    }

    angle

    typenumberrequirednodefault—

    Linear gradients only: angle in degrees (0 = left to right, 90 = top to bottom). Default 90.

    stops

    typearray<object>requiredyesdefault—

    Ordered color stops; at least two. A radial, rectangle or shape gradient runs from the center (position 0) to the outline (position 1).

    Named choices are not exhaustive. See the schema for other values and constraints.
    stops[].color, stops[].color (anyOf 4).color · Named choices
    "accent1", "accent2", "accent3", "accent4", "accent5", "accent6", "dark1", "dark2", "light1", "light2", "hyperlink", "followedHyperlink", "primary", "secondary", "accent", "background", "surface", "surfaceAlt", "text", "textSecondary"
    Complete definition constraints
    Schema constraints
    {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "stops"
      ],
      "description": "A gradient fill: the background gradient object extended with 'type'. DrawingML a:gradFill: a:lin for linear, a:path circle, rect or shape for the others. The gradient rotates with the shape.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "linear",
            "radial",
            "rectangle",
            "shape"
          ],
          "description": "linear runs along 'angle'; radial spreads from the center as a circle, rectangle as a rectangle and shape along the shape's own outline (a:path circle, rect, shape). Default linear."
        },
        "angle": {
          "type": "number",
          "description": "Linear gradients only: angle in degrees (0 = left to right, 90 = top to bottom). Default 90."
        },
        "stops": {
          "type": "array",
          "minItems": 2,
          "description": "Ordered color stops; at least two. A radial, rectangle or shape gradient runs from the center (position 0) to the outline (position 1).",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "color",
              "position"
            ],
            "properties": {
              "color": {
                "$ref": "#/$defs/ColorRef",
                "description": "Stop color: any ColorRef (eight-digit hex keeps its alpha)."
              },
              "position": {
                "type": "number",
                "minimum": 0,
                "maximum": 1,
                "description": "Stop position, 0 to 1."
              }
            }
          }
        }
      },
      "examples": [
        {
          "type": "linear",
          "angle": 90,
          "stops": [
            {
              "color": "accent1",
              "position": 0
            },
            {
              "color": {
                "color": "accent1",
                "darken": 0.5
              },
              "position": 1
            }
          ]
        }
      ]
    }