Fill class

Fill class

Represents fill formatting for an object. To learn more, visit the Working with Graphic Elements documentation article.

Remarks

Use the ShapeBase.fill or Font.fill property to access fill properties of an object. You do not create instances of the Fill class directly.

Properties

NameDescription
backColorGets or sets a Color object that represents the background color for the fill.
backThemeColorGets or sets a ThemeColor object that represents the background color for the fill.
backTintAndShadeGets or sets a double value that lightens or darkens the background color.
baseForeColorGets a Color object that represents the base foreground color for the fill without any modifiers.
colorGets or sets a Color object that represents the foreground color for the fill.
fillTypeGets a fill type.
foreColorGets or sets a Color object that represents the foreground color for the fill.
foreThemeColorGets or sets a ThemeColor object that represents the foreground color for the fill.
foreTintAndShadeGets or sets a double value that lightens or darkens the foreground color.
gradientAngleGets or sets the angle of the gradient fill.
gradientStopsGets a collection of GradientStop objects for the fill.
gradientStyleGets the gradient style GradientStyle for the fill.
gradientVariantGets the gradient variant GradientVariant for the fill.
imageBytesGets the raw bytes of the fill texture or pattern.
opacityGets or sets the degree of opacity of the specified fill as a value between 0.0 (clear) and 1.0 (opaque).
patternGets a PatternType for the fill.
presetTextureGets a PresetTexture for the fill.
rotateWithObjectGets or sets whether the fill rotates with the specified object.
textureAlignmentGets or sets the alignment for tile texture fill.
transparencyGets or sets the degree of transparency of the specified fill as a value between 0.0 (opaque) and 1.0 (clear).
visibleGets or sets value that is true if the formatting applied to this instance, is visible.

Methods

NameDescription
oneColorGradient(style, variant, degree)Sets the specified fill to a one-color gradient.
oneColorGradient(color, style, variant, degree)Sets the specified fill to a one-color gradient using the specified color.
patterned(patternType)Sets the specified fill to a pattern.
patterned(patternType, foreColor, backColor)Sets the specified fill to a pattern.
presetTextured(presetTexture)Sets the fill to a preset texture.
setImage(fileName)Changes the fill type to single image.
setImage(stream)Changes the fill type to single image.
setImage(imageBytes)Changes the fill type to single image.
solid()Sets the fill to a uniform color.
solid(color)Sets the fill to a specified uniform color.
twoColorGradient(style, variant)Sets the specified fill to a two-color gradient.
twoColorGradient(color1, color2, style, variant)Sets the specified fill to a two-color gradient.

Examples

Shows how to fill a shape with a solid color.

let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);

// Write some text, and then cover it with a floating shape.
builder.font.size = 32;
builder.writeln("Hello world!");

let shape = builder.insertShape(aw.Drawing.ShapeType.CloudCallout, aw.Drawing.RelativeHorizontalPosition.LeftMargin, 25,
  aw.Drawing.RelativeVerticalPosition.TopMargin, 25, 250, 150, aw.Drawing.WrapType.None);

// Use the "StrokeColor" property to set the color of the outline of the shape.
shape.strokeColor = "#5F9EA0";

// Use the "FillColor" property to set the color of the inside area of the shape.
shape.fillColor = "#ADD8E6";

// The "Opacity" property determines how transparent the color is on a 0-1 scale,
// with 1 being fully opaque, and 0 being invisible.
// The shape fill by default is fully opaque, so we cannot see the text that this shape is on top of.
expect(shape.fill.opacity).toEqual(1.0);

// Set the shape fill color's opacity to a lower value so that we can see the text underneath it.
shape.fill.opacity = 0.3;

doc.save(base.artifactsDir + "Shape.fill.docx");

See Also