Skip to main content

GetFill

Gets the fill properties from the current shape.

Syntax

expression.GetFill();

expression - A variable that represents a ApiShape class.

Parameters

This method doesn't have any parameters.

Returns

ApiFill | null

Example

Retrieve the fill properties of a shape in a presentation.

// How do I find out what color or pattern fills a shape in a presentation?

// Check the fill type of a shape with a gradient in a presentation.

let presentation = Api.GetPresentation();
let slide = presentation.GetSlideByIndex(0);
let gs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0);
let gs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000);
let fill = Api.CreateLinearGradientFill([gs1, gs2], 5400000);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 100 * 36000, 50 * 36000, fill, stroke);
shape.SetPosition(2000000, 1000000);
slide.AddObject(shape);
let content = shape.GetDocContent();
let paragraph = content.GetElement(0);
let retrievedFill = shape.GetFill();
if (retrievedFill) {
paragraph.AddText("Fill type: " + retrievedFill.GetType());
}