one_color_gradient method
Contents
[
Hide
]one_color_gradient(style, variant, degree)
Sets the specified fill to a one-color gradient.
def one_color_gradient(self, style: aspose.words.drawing.GradientStyle, variant: aspose.words.drawing.GradientVariant, degree: float):
...
Parameter | Type | Description |
---|---|---|
style | GradientStyle | The gradient style GradientStyle |
variant | GradientVariant | The gradient variant GradientVariant |
degree | float | The gradient degree. Can be a value from 0.0 (dark) to 1.0 (light). |
one_color_gradient(color, style, variant, degree)
Sets the specified fill to a one-color gradient using the specified color.
def one_color_gradient(self, color: aspose.pydrawing.Color, style: aspose.words.drawing.GradientStyle, variant: aspose.words.drawing.GradientVariant, degree: float):
...
Parameter | Type | Description |
---|---|---|
color | aspose.pydrawing.Color | The color to build the gradient. |
style | GradientStyle | The gradient style GradientStyle |
variant | GradientVariant | The gradient variant GradientVariant |
degree | float | The gradient degree. Can be a value from 0.0 (dark) to 1.0 (light). |
Examples
Shows how to fill a shape with a gradients.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
shape = builder.insert_shape(shape_type=aw.drawing.ShapeType.RECTANGLE, width=80, height=80)
# Apply One-color gradient fill to the shape with ForeColor of gradient fill.
shape.fill.one_color_gradient(color=aspose.pydrawing.Color.red, style=aw.drawing.GradientStyle.HORIZONTAL, variant=aw.drawing.GradientVariant.VARIANT2, degree=0.1)
self.assertEqual(aspose.pydrawing.Color.red.to_argb(), shape.fill.fore_color.to_argb())
self.assertEqual(aw.drawing.GradientStyle.HORIZONTAL, shape.fill.gradient_style)
self.assertEqual(aw.drawing.GradientVariant.VARIANT2, shape.fill.gradient_variant)
self.assertEqual(270, shape.fill.gradient_angle)
shape = builder.insert_shape(shape_type=aw.drawing.ShapeType.RECTANGLE, width=80, height=80)
# Apply Two-color gradient fill to the shape.
shape.fill.two_color_gradient(style=aw.drawing.GradientStyle.FROM_CORNER, variant=aw.drawing.GradientVariant.VARIANT4)
# Change BackColor of gradient fill.
shape.fill.back_color = aspose.pydrawing.Color.yellow
# Note that changes "GradientAngle" for "GradientStyle.FromCorner/GradientStyle.FromCenter"
# gradient fill don't get any effect, it will work only for linear gradient.
shape.fill.gradient_angle = 15
self.assertEqual(aspose.pydrawing.Color.yellow.to_argb(), shape.fill.back_color.to_argb())
self.assertEqual(aw.drawing.GradientStyle.FROM_CORNER, shape.fill.gradient_style)
self.assertEqual(aw.drawing.GradientVariant.VARIANT4, shape.fill.gradient_variant)
self.assertEqual(0, shape.fill.gradient_angle)
# Use the compliance option to define the shape using DML if you want to get "GradientStyle",
# "GradientVariant" and "GradientAngle" properties after the document saves.
save_options = aw.saving.OoxmlSaveOptions()
save_options.compliance = aw.saving.OoxmlCompliance.ISO29500_2008_STRICT
doc.save(file_name=ARTIFACTS_DIR + 'Shape.GradientFill.docx', save_options=save_options)
See Also
- module aspose.words.drawing
- class Fill