# OfficeLinearGradient

Dependency-free linear gradient intent in normalized local coordinates.

Class 

`OfficeIMO.Drawing`

**Namespace**

`OfficeIMO.Drawing`

**Assembly**

`OfficeIMO.Core`

**Source revision**

`ba882f6b0d07` with working tree changes

**Source**

[OfficeLinearGradient.cs:38](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L38)

**Modifiers**

sealed

Dependency-free linear gradient intent in normalized local coordinates. Coordinates use a top-left origin where 0,0 is the shape's top-left corner and 1,1 is its bottom-right corner. Importers may preserve finite user-space vectors that cross those bounds without weakening public constructor validation.

## Inheritance

- object
- OfficeLinearGradient

## Usage

Explore 12 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 9

- Method [OfficeLinearGradient.Clone](/api/core/officeimo-drawing-officelineargradient/#method-clone)
- Method [OfficeLinearGradient.DiagonalDown](/api/core/officeimo-drawing-officelineargradient/#method-diagonaldown-officeimo-officecolor-officeimo-officecolor)
- Method [OfficeLinearGradient.FromAngle](/api/core/officeimo-drawing-officelineargradient/#method-fromangle-officeimo-officecolor-officeimo-officecolor-double)
- Method [OfficeLinearGradient.FromTransformedAngle](/api/core/officeimo-drawing-officelineargradient/#method-fromtransformedangle-collections-generic-ireadonlylist-officeimo-drawing-officegradientstop-double-double-double-officeimo-drawing-officetransform)
- Method [OfficeLinearGradient.Horizontal](/api/core/officeimo-drawing-officelineargradient/#method-horizontal-officeimo-officecolor-officeimo-officecolor)
- Method [OfficeLinearGradient.Vertical](/api/core/officeimo-drawing-officelineargradient/#method-vertical-officeimo-officecolor-officeimo-officecolor)
- Method [OfficeLinearGradient.WithColorInterpolation](/api/core/officeimo-drawing-officelineargradient/#method-withcolorinterpolation-officeimo-drawing-officegradientcolorinterpolation)
- Property [OfficeShape.FillGradient](/api/core/officeimo-drawing-officeshape/#property-fillgradient)
- Property [OfficeShape.StrokeGradient](/api/core/officeimo-drawing-officeshape/#property-strokegradient)

### Accepted by parameters 3

- Method [OfficeRasterCanvas.FillLinearGradientPolygon](/api/core/officeimo-drawing-officerastercanvas/#method-filllineargradientpolygon-collections-generic-ireadonlylist-officeimo-drawing-officepoint-officeimo-drawing-officelineargradient) parameter `gradient`
- Method [OfficeRasterCanvas.FillLinearGradientRectangle](/api/core/officeimo-drawing-officerastercanvas/#method-filllineargradientrectangle-double-double-double-double-officeimo-drawing-officelineargradient) parameter `gradient`
- Method [OfficeSvgFormatting.AppendLinearGradientDefinition](/api/core/officeimo-drawing-officesvgformatting/#method-appendlineargradientdefinition-text-stringbuilder-string-officeimo-drawing-officelineargradient) parameter `gradient`

Filter members 

Show inherited

## Constructors

OfficeLinearGradient 2 overloads

`public OfficeLinearGradient(double startX, double startY, double endX, double endY, OfficeGradientStop start, OfficeGradientStop end)` [#](#constructor-ctor-double-double-double-double-officeimo-drawing-officegradientstop-officeimo-drawing-officegradientstop)

[OfficeLinearGradient.cs:38](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L38)

Creates a two-stop linear gradient.

Parameters

**startX double required**

**startY double required**

**endX double required**

**endY double required**

**start OfficeIMO.Drawing.OfficeGradientStop required**

**end OfficeIMO.Drawing.OfficeGradientStop required**

`public OfficeLinearGradient(double startX, double startY, double endX, double endY, IReadOnlyList<OfficeGradientStop> stops)` [#](#constructor-ctor-double-double-double-double-collections-generic-ireadonlylist-officeimo-drawing-officegradientstop)

[OfficeLinearGradient.cs:43](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L43)

Creates a linear gradient with two or more ordered stops.

Parameters

**startX double required**

**startY double required**

**endX double required**

**endY double required**

**stops System.Collections.Generic.IReadOnlyList<OfficeIMO.Drawing.OfficeGradientStop> required**

## Methods

`public OfficeLinearGradient Clone()` [#](#method-clone)

[OfficeLinearGradient.cs:184](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L184)

Creates a detached copy.

Returns

`OfficeLinearGradient`

`public static OfficeLinearGradient DiagonalDown(OfficeColor startColor, OfficeColor endColor)` [#](#method-diagonaldown-officeimo-officecolor-officeimo-officecolor)

[OfficeLinearGradient.cs:98](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L98)

Creates a diagonal top-left to bottom-right gradient.

Parameters

**startColor OfficeIMO.OfficeColor required**

**endColor OfficeIMO.OfficeColor required**

Returns

`OfficeLinearGradient`

FromAngle 2 overloads

`public static OfficeLinearGradient FromAngle(OfficeColor startColor, OfficeColor endColor, double degrees)` [#](#method-fromangle-officeimo-officecolor-officeimo-officecolor-double)

[OfficeLinearGradient.cs:108](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L108)

Creates a two-stop gradient projected through the normalized drawing rectangle at the supplied angle.

Parameters

**startColor OfficeIMO.OfficeColor required**

Color at offset 0.

**endColor OfficeIMO.OfficeColor required**

Color at offset 1.

**degrees double required**

Clockwise angle in degrees where 0 is left-to-right in local coordinates.

Returns

`OfficeLinearGradient` A gradient with endpoints clamped to the normalized drawing rectangle.

`public static OfficeLinearGradient FromAngle(IReadOnlyList<OfficeGradientStop> stops, double degrees)` [#](#method-fromangle-collections-generic-ireadonlylist-officeimo-drawing-officegradientstop-double)

[OfficeLinearGradient.cs:123](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L123)

Creates a gradient with ordered stops projected through the normalized drawing rectangle at the supplied angle.

Parameters

**stops System.Collections.Generic.IReadOnlyList<OfficeIMO.Drawing.OfficeGradientStop> required**

Gradient stops. The first stop must be offset 0 and the last stop must be offset 1.

**degrees double required**

Clockwise angle in degrees where 0 is left-to-right in local coordinates.

Returns

`OfficeLinearGradient` A gradient with endpoints clamped to the normalized drawing rectangle.

`public static OfficeLinearGradient FromTransformedAngle(IReadOnlyList<OfficeGradientStop> stops, double destinationDegrees, double localWidth, double localHeight, OfficeTransform localToDestination)` [#](#method-fromtransformedangle-collections-generic-ireadonlylist-officeimo-drawing-officegradientstop-double-double-double-officeimo-drawing-officetransform)

[OfficeLinearGradient.cs:159](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L159)

Creates a local-coordinate gradient whose color-field normal follows the supplied angle after an affine shape transform.

Parameters

**stops System.Collections.Generic.IReadOnlyList<OfficeIMO.Drawing.OfficeGradientStop> required**

Gradient stops. The first stop must use offset 0 and the last stop offset 1.

**destinationDegrees double required**

Clockwise gradient angle in destination coordinates.

**localWidth double required**

Width of the shape's local coordinate box.

**localHeight double required**

Height of the shape's local coordinate box.

**localToDestination OfficeIMO.Drawing.OfficeTransform required**

Affine transform applied to the shape after its local gradient is evaluated.

Returns

`OfficeLinearGradient` A local normalized gradient that preserves the requested destination-space color-field direction.

`public static OfficeLinearGradient Horizontal(OfficeColor startColor, OfficeColor endColor)` [#](#method-horizontal-officeimo-officecolor-officeimo-officecolor)

[OfficeLinearGradient.cs:90](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L90)

Creates a horizontal left-to-right gradient.

Parameters

**startColor OfficeIMO.OfficeColor required**

**endColor OfficeIMO.OfficeColor required**

Returns

`OfficeLinearGradient`

`public static OfficeLinearGradient Vertical(OfficeColor startColor, OfficeColor endColor)` [#](#method-vertical-officeimo-officecolor-officeimo-officecolor)

[OfficeLinearGradient.cs:94](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L94)

Creates a vertical top-to-bottom gradient.

Parameters

**startColor OfficeIMO.OfficeColor required**

**endColor OfficeIMO.OfficeColor required**

Returns

`OfficeLinearGradient`

`public OfficeLinearGradient WithColorInterpolation(OfficeGradientColorInterpolation interpolation)` [#](#method-withcolorinterpolation-officeimo-drawing-officegradientcolorinterpolation)

[OfficeLinearGradient.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L28)

Returns a detached gradient using the specified color interpolation space.

Parameters

**interpolation OfficeIMO.Drawing.OfficeGradientColorInterpolation required**

Returns

`OfficeLinearGradient`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public double StartX { get; }` [#](#property-startx)

[OfficeLinearGradient.cs:12](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L12)

Normalized start X coordinate.

`public double StartY { get; }` [#](#property-starty)

[OfficeLinearGradient.cs:15](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L15)

Normalized start Y coordinate.

`public double EndX { get; }` [#](#property-endx)

[OfficeLinearGradient.cs:18](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L18)

Normalized end X coordinate.

`public double EndY { get; }` [#](#property-endy)

[OfficeLinearGradient.cs:21](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L21)

Normalized end Y coordinate.

`public OfficeGradientColorInterpolation ColorInterpolation { get; private set; }` [#](#property-colorinterpolation)

[OfficeLinearGradient.cs:24](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L24)

Color space used to interpolate RGB channels between stops. Defaults to encoded sRGB.

`public IReadOnlyList<OfficeGradientStop> Stops { get; }` [#](#property-stops)

[OfficeLinearGradient.cs:34](https://github.com/EvotecIT/OfficeIMO/blob/ba882f6b0d07acddd884b5e7d3086b0cfff0a05a/OfficeIMO.Core/OfficeLinearGradient.cs#L34)

Gradient stops in offset order.

<!-- PowerForge markdown artifact sha256:E9BA81BEFA90A56B7BC7DEB0264C698D57C207325B8B507DA9FBED083D5D87FE -->
