GradientFormat / PatternFormat

GradientFormat / PatternFormat — Aspose.Slides FOSS for .NET API Reference

These classes define gradient and pattern fill details, accessed via FillFormat.GradientFormat and FillFormat.PatternFormat.

Package: Aspose.Slides.Foss (net9.0)

using Aspose.Slides.Foss;

GradientFormat

public class GradientFormat : IGradientFormat

Properties

PropertyTypeAccessDescription
GradientStopsIGradientStopCollectionReadCollection of gradient color stops.
GradientDirectionGradientDirectionReadGradient direction.
GradientShapeGradientShapeReadGradient shape (Linear, Rectangular, etc.).
LinearGradientAnglefloatReadAngle for linear gradients.
LinearGradientScaledNullableBoolReadWhether the gradient is scaled.
TileFlipTileFlipReadTile flip mode for the gradient.

GradientStop

public class GradientStop : PVIObject, IGradientStop

Properties

PropertyTypeAccessDescription
PositionfloatReadPosition along the gradient (0.0–1.0).
ColorIColorFormatReadColor at this stop.

GradientStopCollection

public class GradientStopCollection : PVIObject, IGradientStopCollection

Properties

PropertyTypeAccessDescription
CountintReadNumber of gradient stops.

Methods

MethodDescription
Add(float position, Color color)Add a stop with an RGB color.
Add(float position, PresetColor presetColor)Add a stop with a preset color.
Add(float position, SchemeColor schemeColor)Add a stop with a scheme color.
Insert(int index, float position, Color color)Insert a stop at a specific index.
RemoveAt(int index)Remove the stop at the specified index.
Clear()Remove all stops.

PatternFormat

public class PatternFormat : PVIObject, IPatternFormat

Properties

PropertyTypeAccessDescription
PatternStylePatternStyleReadPattern style (e.g., Cross, DiagonalBrick, etc.).
ForeColorIColorFormatReadForeground color of the pattern.
BackColorIColorFormatReadBackground color of the pattern.

Usage Examples

Read Gradient Stops

using Aspose.Slides.Foss;

using var prs = new Presentation("deck.pptx");
var shape = prs.Slides[0].Shapes[0];
if (shape.FillFormat.FillType == FillType.Gradient)
{
    var grad = shape.FillFormat.GradientFormat;
    Console.WriteLine($"Direction: {grad.GradientDirection}");
    foreach (var stop in grad.GradientStops)
    {
        Console.WriteLine($"  Position {stop.Position}: {stop.Color.Color}");
    }
}

Read Pattern Fill

using Aspose.Slides.Foss;

using var prs = new Presentation("deck.pptx");
var shape = prs.Slides[0].Shapes[0];
if (shape.FillFormat.FillType == FillType.Pattern)
{
    var pat = shape.FillFormat.PatternFormat;
    Console.WriteLine($"Style: {pat.PatternStyle}");
    Console.WriteLine($"Foreground: {pat.ForeColor.Color}");
    Console.WriteLine($"Background: {pat.BackColor.Color}");
}

See Also