GradientFormat / PatternFormat

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

The GradientFormat and PatternFormat classes control gradient and pattern fill properties for shapes. Both extend PVIObject.

Package: org.aspose.slides.foss

import org.aspose.slides.foss.*;

GradientFormat

public class GradientFormat extends PVIObject implements IGradientFormat, IFillParamSource

Properties

PropertyTypeAccessDescription
getGradientDirection() / setGradientDirection(GradientDirection)GradientDirectionRead/WriteGradient direction (linear, path, etc.).
getGradientShape()GradientShapeReadGradient shape.
getLinearGradientAngle() / setLinearGradientAngle(double)doubleRead/WriteAngle for linear gradients (degrees).
getLinearGradientScaled() / setLinearGradientScaled(NullableBool)NullableBoolRead/WriteWhether the gradient is scaled.
getTileFlip() / setTileFlip(TileFlip)TileFlipRead/WriteTile flip mode.
getGradientStops()IGradientStopCollectionReadCollection of gradient stops.

Usage Example

import org.aspose.slides.foss.*;
import java.awt.Color;

IAutoShape shape = slide.getShapes().addAutoShape(
    ShapeType.RECTANGLE, 50, 50, 200, 100);
IFillFormat fill = shape.getFillFormat();
fill.setFillType(FillType.GRADIENT);

IGradientFormat grad = fill.getGradientFormat();
grad.setGradientDirection(GradientDirection.FROM_CORNER1);
grad.setLinearGradientAngle(45.0);

PatternFormat

public class PatternFormat extends PVIObject implements IPatternFormat

Properties

PropertyTypeAccessDescription
getPatternStyle() / setPatternStyle(PatternStyle)PatternStyleRead/WritePattern style (e.g., PERCENT05, HORIZONTAL, etc.).
getForeColor()IColorFormatReadForeground color of the pattern.
getBackColor()IColorFormatReadBackground color of the pattern.

Usage Example

IFillFormat fill = shape.getFillFormat();
fill.setFillType(FillType.PATTERN);
IPatternFormat pattern = fill.getPatternFormat();
pattern.setPatternStyle(PatternStyle.HORIZONTAL);
pattern.getForeColor().setColor(Color.BLACK);
pattern.getBackColor().setColor(Color.WHITE);

See Also