Aspose::Words::Drawing::Fill Class Reference

Detailed Description

Defines a fill for a shape.

Use the Fill property to access fill properties of a shape. You do not create instances of the Fill class directly.

Although the Fill class provides properties to specify solid color fill only, all of the more complex fill types, including as gradient, pattern and texture are fully preserved during document open-save cycles.

See also
Aspose::Words::Drawing::Shape::get_Fill
Examples

Demonstrates how to create shapes with fill.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln();
builder->Writeln();
builder->Writeln();
builder->Write(u"Some text under the shape.");
// Create a red balloon, semitransparent
// The shape is floating and its coordinates are (0,0) by default, relative to the current paragraph
auto shape = MakeObject<Shape>(builder->get_Document(), Aspose::Words::Drawing::ShapeType::Balloon);
shape->set_FillColor(System::Drawing::Color::get_Red());
shape->get_Fill()->set_Opacity(0.3);
shape->set_Width(100);
shape->set_Height(100);
shape->set_Top(-100);
builder->InsertNode(shape);
doc->Save(ArtifactsDir + u"Shape.Fill.docx");

#include <Aspose.Words.Cpp/Model/Drawing/Fill.h>

+ Inheritance diagram for Aspose::Words::Drawing::Fill:

Public Member Functions

Color get_Color ()
 Defines the color of a fill. More...
 
ArrayPtr< uint8_t > get_ImageBytes ()
 Gets the raw bytes of the fill texture or pattern. More...
 
bool get_On ()
 Determines whether the shape will be filled. More...
 
double get_Opacity ()
 Defines the transparency of a fill. Valid range from 0 to 1, where 0 is fully transparent and 1 is fully opaque. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_Color (Color value)
 Setter for get_Color. More...
 
void set_On (bool value)
 Setter for get_On. More...
 
void set_Opacity (double value)
 Setter for get_Opacity. More...
 
- Public Member Functions inherited from Object
ASPOSECPP_SHARED_API Object ()
 
ASPOSECPP_SHARED_API Object (Object const &x)
 
virtual ASPOSECPP_SHARED_API ~Object ()
 
virtual ASPOSECPP_SHARED_API bool Equals (ptr obj)
 
Detail::SmartPtrCounter * GetCounter ()
 
virtual ASPOSECPP_SHARED_API int GetHashCode () const
 
ASPOSECPP_SHARED_API void Lock ()
 
virtual ASPOSECPP_SHARED_API ptr MemberwiseClone () const
 
Objectoperator= (Object const &x)
 
bool ReferenceEquals (String const &str, std::nullptr_t)
 
bool ReferenceEquals (String const &str1, String const &str2)
 
int RemovedSharedRefs (int count)
 
virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr (unsigned int argument)
 
int SharedCount () const
 
ObjectSharedRefAdded ()
 
int SharedRefRemovedSafe ()
 
virtual ASPOSECPP_SHARED_API String ToString () const
 
ASPOSECPP_SHARED_API void Unlock ()
 
Detail::SmartPtrCounter * WeakRefAdded ()
 
void WeakRefRemoved ()
 

Static Public Member Functions

static const TypeInfoType ()
 
- Static Public Member Functions inherited from Object
bool Equals (double const &objA, double const &objB)
 
bool Equals (float const &objA, float const &objB)
 
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals (T1 const &objA, T2 const &objB)
 
static bool ReferenceEquals (ptr const &objA, ptr const &objB)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, std::nullptr_t)
 
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals (T const &objA, T const &objB)
 
static const TypeInfoType ()
 

Additional Inherited Members

- Public Types inherited from Object
typedef SmartPtr< Objectptr
 
typedef System::Details::SharedMembersType shared_members_type
 

Member Function Documentation

◆ get_Color()

System::Drawing::Color Aspose::Words::Drawing::Fill::get_Color ( )

Defines the color of a fill.

The default value is White.

Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Draw a dotted horizontal half-transparent red line with an arrow on the left end and a diamond on the other
auto arrow = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(Aspose::Words::Drawing::ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(Aspose::Words::Drawing::ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(Aspose::Words::Drawing::ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(Aspose::Words::Drawing::ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(Aspose::Words::Drawing::ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(Aspose::Words::Drawing::ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(Aspose::Words::Drawing::DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(Aspose::Words::Drawing::JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// Draw a thick black diagonal line with rounded ends
auto line = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(Aspose::Words::Drawing::EndCap::Round);
builder->InsertNode(line);
// Draw an arrow with a green fill
auto filledInArrow = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_Color(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_On(true);
builder->InsertNode(filledInArrow);
// Draw an arrow filled in with the Aspose logo and flip its orientation
auto filledInArrowImg = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(Aspose::Words::Drawing::FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = webClient->DownloadData(AsposeLogoUrl);
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flipped the orientation of our arrow, the image content was flipped too
// If we want it to be displayed the right side up, we have to reverse the arrow flip on the image
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(Aspose::Words::Drawing::JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");

◆ get_ImageBytes()

System::ArrayPtr<uint8_t> Aspose::Words::Drawing::Fill::get_ImageBytes ( )

Gets the raw bytes of the fill texture or pattern.

The default value is null.

Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Draw a dotted horizontal half-transparent red line with an arrow on the left end and a diamond on the other
auto arrow = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(Aspose::Words::Drawing::ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(Aspose::Words::Drawing::ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(Aspose::Words::Drawing::ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(Aspose::Words::Drawing::ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(Aspose::Words::Drawing::ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(Aspose::Words::Drawing::ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(Aspose::Words::Drawing::DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(Aspose::Words::Drawing::JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// Draw a thick black diagonal line with rounded ends
auto line = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(Aspose::Words::Drawing::EndCap::Round);
builder->InsertNode(line);
// Draw an arrow with a green fill
auto filledInArrow = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_Color(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_On(true);
builder->InsertNode(filledInArrow);
// Draw an arrow filled in with the Aspose logo and flip its orientation
auto filledInArrowImg = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(Aspose::Words::Drawing::FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = webClient->DownloadData(AsposeLogoUrl);
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flipped the orientation of our arrow, the image content was flipped too
// If we want it to be displayed the right side up, we have to reverse the arrow flip on the image
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(Aspose::Words::Drawing::JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");

◆ get_On()

bool Aspose::Words::Drawing::Fill::get_On ( )

Determines whether the shape will be filled.

The default value is true.

Examples

Shows to create a variety of shapes.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
// Draw a dotted horizontal half-transparent red line with an arrow on the left end and a diamond on the other
auto arrow = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Line);
arrow->set_Width(200);
arrow->get_Stroke()->set_Color(System::Drawing::Color::get_Red());
arrow->get_Stroke()->set_StartArrowType(Aspose::Words::Drawing::ArrowType::Arrow);
arrow->get_Stroke()->set_StartArrowLength(Aspose::Words::Drawing::ArrowLength::Long);
arrow->get_Stroke()->set_StartArrowWidth(Aspose::Words::Drawing::ArrowWidth::Wide);
arrow->get_Stroke()->set_EndArrowType(Aspose::Words::Drawing::ArrowType::Diamond);
arrow->get_Stroke()->set_EndArrowLength(Aspose::Words::Drawing::ArrowLength::Long);
arrow->get_Stroke()->set_EndArrowWidth(Aspose::Words::Drawing::ArrowWidth::Wide);
arrow->get_Stroke()->set_DashStyle(Aspose::Words::Drawing::DashStyle::Dash);
arrow->get_Stroke()->set_Opacity(0.5);
ASSERT_EQ(Aspose::Words::Drawing::JoinStyle::Miter, arrow->get_Stroke()->get_JoinStyle());
builder->InsertNode(arrow);
// Draw a thick black diagonal line with rounded ends
auto line = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Line);
line->set_Top(40);
line->set_Width(200);
line->set_Height(20);
line->set_StrokeWeight(5.0);
line->get_Stroke()->set_EndCap(Aspose::Words::Drawing::EndCap::Round);
builder->InsertNode(line);
// Draw an arrow with a green fill
auto filledInArrow = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Arrow);
filledInArrow->set_Width(200);
filledInArrow->set_Height(40);
filledInArrow->set_Top(100);
filledInArrow->get_Fill()->set_Color(System::Drawing::Color::get_Green());
filledInArrow->get_Fill()->set_On(true);
builder->InsertNode(filledInArrow);
// Draw an arrow filled in with the Aspose logo and flip its orientation
auto filledInArrowImg = MakeObject<Shape>(doc, Aspose::Words::Drawing::ShapeType::Arrow);
filledInArrowImg->set_Width(200);
filledInArrowImg->set_Height(40);
filledInArrowImg->set_Top(160);
filledInArrowImg->set_FlipOrientation(Aspose::Words::Drawing::FlipOrientation::Both);
{
auto webClient = MakeObject<System::Net::WebClient>();
ArrayPtr<uint8_t> imageBytes = webClient->DownloadData(AsposeLogoUrl);
{
auto stream = MakeObject<System::IO::MemoryStream>(imageBytes);
SharedPtr<System::Drawing::Image> image = System::Drawing::Image::FromStream(stream);
// When we flipped the orientation of our arrow, the image content was flipped too
// If we want it to be displayed the right side up, we have to reverse the arrow flip on the image
filledInArrowImg->get_ImageData()->SetImage(image);
filledInArrowImg->get_Stroke()->set_JoinStyle(Aspose::Words::Drawing::JoinStyle::Round);
builder->InsertNode(filledInArrowImg);
}
}
doc->Save(ArtifactsDir + u"Drawing.VariousShapes.docx");

◆ get_Opacity()

double Aspose::Words::Drawing::Fill::get_Opacity ( )

Defines the transparency of a fill. Valid range from 0 to 1, where 0 is fully transparent and 1 is fully opaque.

The default value is 1.

Examples

Demonstrates how to create shapes with fill.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
builder->Writeln();
builder->Writeln();
builder->Writeln();
builder->Write(u"Some text under the shape.");
// Create a red balloon, semitransparent
// The shape is floating and its coordinates are (0,0) by default, relative to the current paragraph
auto shape = MakeObject<Shape>(builder->get_Document(), Aspose::Words::Drawing::ShapeType::Balloon);
shape->set_FillColor(System::Drawing::Color::get_Red());
shape->get_Fill()->set_Opacity(0.3);
shape->set_Width(100);
shape->set_Height(100);
shape->set_Top(-100);
builder->InsertNode(shape);
doc->Save(ArtifactsDir + u"Shape.Fill.docx");

◆ GetType()

virtual const System::TypeInfo& Aspose::Words::Drawing::Fill::GetType ( ) const
overridevirtual

Reimplemented from System::Object.

◆ Is()

virtual bool Aspose::Words::Drawing::Fill::Is ( const System::TypeInfo target) const
overridevirtual

Reimplemented from System::Object.

◆ set_Color()

void Aspose::Words::Drawing::Fill::set_Color ( System::Drawing::Color  value)

◆ set_On()

void Aspose::Words::Drawing::Fill::set_On ( bool  value)

◆ set_Opacity()

void Aspose::Words::Drawing::Fill::set_Opacity ( double  value)

◆ Type()

static const System::TypeInfo& Aspose::Words::Drawing::Fill::Type ( )
static
@ Arrow
The arrow is a solid triangle.
@ Wide
static ASPOSECPP_SHARED_API SharedPtr< Image > FromStream(const SharedPtr< System::IO::Stream > &stream, bool use_embedded_color_management=false, bool validate_image_data=1)
@ Both
Flip along both the y- and x-axis.
@ Round
Draw an arc between the two edges.
@ Dash
Dash style.
@ Arrow
@ RotateNoneFlipXY
@ Diamond
The line end is a solid diamond.
@ Line
static ASPOSECPP_SHARED_API Color get_Green()
@ Miter
Extend edges until they join.
@ Balloon
@ Long
static ASPOSECPP_SHARED_API Color get_Red()
@ Round
Rounded ends.