xtd - Reference Guide  0.1.2
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
xtd::drawing::drawing2d::linear_gradient_brush Class Referencefinal

#include <linear_gradient_brush.h>

Definition

Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.

Namespace
xtd::drawing::drawing2d
Library
xtd.drawing
Examples
The following code example demonstrate the use of linear_gradient_brush class.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::drawing::drawing2d;
using namespace xtd::forms;
namespace examples {
class form1 : public form {
public:
form1() {
text("Fill rectangle example");
client_size({340, 230});
}
protected:
void on_paint(paint_event_args& e) override {
e.graphics().fill_rectangle(brushes::transparent(), 10, 10, 100, 100);
e.graphics().fill_rectangle(solid_brush(color::red), 120, 10, 100, 100);
e.graphics().fill_rectangle(linear_gradient_brush(rectangle(230, 10, 100, 100), color::green, color::white, linear_gradient_mode::horizontal), 230, 10, 100, 100);
e.graphics().fill_rectangle(hatch_brush(hatch_style::diagonal_brick, color::blue, color::white), 10, 120, 100, 100);
e.graphics().fill_rectangle(texture_brush(create_circle_texture(color::yellow)), 120, 120, 100, 100);
form::on_paint(e);
}
private:
image create_circle_texture(const color& color) {
auto texture = bitmap(16, 16);
auto graphics = texture.create_graphics();
graphics.fill_ellipse(solid_brush(color), 0, 0, texture.width() - 1, texture.height() - 1);
graphics.draw_ellipse(pens::black(), 0, 0, texture.width() - 1, texture.height() - 1);
return texture;
}
};
}
int main() {
application::run(examples::form1());
}
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.h:19
Represents an ARGB (alpha, red, green, blue) color.
Definition color.h:39
Defines a rectangular xtd::drawing::brush with a hatch style, a foreground color, and a background co...
Definition hatch_brush.h:31
Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.
Definition linear_gradient_brush.h:28
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.h:48
void draw_ellipse(const xtd::drawing::pen &pen, const xtd::drawing::rectangle &rect)
Draws an ellipse specified by a bounding xtd::drawing::rectangle structure.
Definition graphics.h:142
An abstract base class that provides functionality for the bitmap and metafile descended classes.
Definition image.h:34
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.h:25
Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes,...
Definition solid_brush.h:22
Each property of the xtd::drawing::texture_brush class is a xtd::drawing::brush object that uses an i...
Definition texture_brush.h:22
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:40
Provides data for the paint event.
Definition paint_event_args.h:26
@ e
The E key.
The xtd::.drawing::drawing2d namespace provides advanced two-dimensional and vector graphics function...
Definition hatch_brush.h:19
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition bitmap.h:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition about_box.h:13
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition system_report.h:17
Examples
fill_rectangle.cpp.

Inherits xtd::drawing::brush.

Public Member Functions

 linear_gradient_brush ()
 Initializes a new instance of the linear_gradient_brush class.
 
 linear_gradient_brush (const xtd::drawing::point &point1, const xtd::drawing::point &point2, const xtd::drawing::color &color1, const xtd::drawing::color &color2)
 Initializes a new instance of the linear_gradient_brush class with the specified points and colors.
 
 linear_gradient_brush (const xtd::drawing::point_f &point1, const xtd::drawing::point_f &point2, const xtd::drawing::color &color1, const xtd::drawing::color &color2)
 Initializes a new instance of the linear_gradient_brush class with the specified points and colors.
 
 linear_gradient_brush (const xtd::drawing::rectangle &rect, const xtd::drawing::color &color1, const xtd::drawing::color &color2)
 Initializes a new instance of the linear_gradient_brush class with the specified rectangle and colors.
 
 linear_gradient_brush (const xtd::drawing::rectangle &rect, const xtd::drawing::color &color1, const xtd::drawing::color &color2, xtd::drawing::drawing2d::linear_gradient_mode linear_gradient_mode)
 Initializes a new instance of the linear_gradient_brush class with the specified rectangle, colors, and orientation.
 
 linear_gradient_brush (const xtd::drawing::rectangle_f &rect, const xtd::drawing::color &color1, const xtd::drawing::color &color2)
 Initializes a new instance of the linear_gradient_brush class with the specified rectangle and colors.
 
 linear_gradient_brush (const xtd::drawing::rectangle_f &rect, const xtd::drawing::color &color1, const xtd::drawing::color &color2, xtd::drawing::drawing2d::linear_gradient_mode linear_gradient_mode)
 Initializes a new instance of the linear_gradient_brush class with the specified rectangle, colors, and orientation.
 
std::array< xtd::drawing::color, 2 > & linear_colors ()
 Gets the starting and ending colors of the gradient.
 
const std::array< xtd::drawing::color, 2 > & linear_colors () const
 Gets the starting and ending colors of the gradient.
 
xtd::drawing::drawing2d::linear_gradient_brushlinear_colors (const std::array< xtd::drawing::color, 2 > &linear_colors)
 sets the starting and ending colors of the gradient.
 
xtd::drawing::rectangle_f rectangle () const
 Gets a rectangular region that defines the starting and ending points of the gradient.
 
- Public Member Functions inherited from xtd::drawing::brush
xtd::ustring to_string () const noexcept override
 Converts this brush object to a human-readable string.
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance.
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object.
 

Additional Inherited Members

- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 
- Protected Member Functions inherited from xtd::drawing::brush
 brush ()
 Initialize a new instance of brush class.
 
void set_native_brush (intptr_t brush)
 In a derived class, sets a reference to a GDI+ brush object.
 

Constructor & Destructor Documentation

◆ linear_gradient_brush() [1/7]

xtd::drawing::drawing2d::linear_gradient_brush::linear_gradient_brush ( )

Initializes a new instance of the linear_gradient_brush class.

◆ linear_gradient_brush() [2/7]

xtd::drawing::drawing2d::linear_gradient_brush::linear_gradient_brush ( const xtd::drawing::point point1,
const xtd::drawing::point point2,
const xtd::drawing::color color1,
const xtd::drawing::color color2 
)
inline

Initializes a new instance of the linear_gradient_brush class with the specified points and colors.

Parameters
point1A xtd::drawing::point structure that represents the starting point of the linear gradient.
point2A xtd::drawing::point structure that represents the endpoint of the linear gradient.
color1A xtd::drawing::color structure that represents the starting color of the linear gradient.
color2A xtd::drawing::color structure that represents the ending color of the linear gradient.

◆ linear_gradient_brush() [3/7]

xtd::drawing::drawing2d::linear_gradient_brush::linear_gradient_brush ( const xtd::drawing::point_f point1,
const xtd::drawing::point_f point2,
const xtd::drawing::color color1,
const xtd::drawing::color color2 
)
inline

Initializes a new instance of the linear_gradient_brush class with the specified points and colors.

Parameters
point1A xtd::drawing::point_f structure that represents the starting point of the linear gradient.
point2A xtd::drawing::point_f structure that represents the endpoint of the linear gradient.
color1A xtd::drawing::color structure that represents the starting color of the linear gradient.
color2A xtd::drawing::color structure that represents the ending color of the linear gradient.

◆ linear_gradient_brush() [4/7]

xtd::drawing::drawing2d::linear_gradient_brush::linear_gradient_brush ( const xtd::drawing::rectangle_f rect,
const xtd::drawing::color color1,
const xtd::drawing::color color2 
)
inline

Initializes a new instance of the linear_gradient_brush class with the specified rectangle and colors.

Parameters
rectA xtd::drawing::rectangle_f structure that specifies the bounds of the linear gradient.
color1A xtd::drawing::color structure that represents the starting color of the linear gradient.
color2A xtd::drawing::color structure that represents the ending color of the linear gradient.

◆ linear_gradient_brush() [5/7]

xtd::drawing::drawing2d::linear_gradient_brush::linear_gradient_brush ( const xtd::drawing::rectangle_f rect,
const xtd::drawing::color color1,
const xtd::drawing::color color2,
xtd::drawing::drawing2d::linear_gradient_mode  linear_gradient_mode 
)
inline

Initializes a new instance of the linear_gradient_brush class with the specified rectangle, colors, and orientation.

Parameters
rectA xtd::drawing::rectangle_f structure that specifies the bounds of the linear gradient.
color1A xtd::drawing::color structure that represents the starting color of the linear gradient.
color2A xtd::drawing::color structure that represents the ending color of the linear gradient.
linear_gradient_modeA xtd::drawing::drawing2d::linear_gradient_mode enumeration element that specifies the orientation of the gradient. The orientation determines the starting and ending points of the gradient. For example, xtd::drawing::drawing2d::linear_gradient_mode::forward_diagonal specifies that the starting point is the upper-left corner of the rectangle and the ending point is the lower-right corner of the rectangle.

◆ linear_gradient_brush() [6/7]

xtd::drawing::drawing2d::linear_gradient_brush::linear_gradient_brush ( const xtd::drawing::rectangle rect,
const xtd::drawing::color color1,
const xtd::drawing::color color2 
)
inline

Initializes a new instance of the linear_gradient_brush class with the specified rectangle and colors.

Parameters
rectA xtd::drawing::rectangle_f structure that specifies the bounds of the linear gradient.
color1A xtd::drawing::color structure that represents the starting color of the linear gradient.
color2A xtd::drawing::color structure that represents the ending color of the linear gradient.

◆ linear_gradient_brush() [7/7]

xtd::drawing::drawing2d::linear_gradient_brush::linear_gradient_brush ( const xtd::drawing::rectangle rect,
const xtd::drawing::color color1,
const xtd::drawing::color color2,
xtd::drawing::drawing2d::linear_gradient_mode  linear_gradient_mode 
)
inline

Initializes a new instance of the linear_gradient_brush class with the specified rectangle, colors, and orientation.

Parameters
rectA xtd::drawing::rectangle structure that specifies the bounds of the linear gradient.
color1A xtd::drawing::color structure that represents the starting color of the linear gradient.
color2A xtd::drawing::color structure that represents the ending color of the linear gradient.
linear_gradient_modeA xtd::drawing::drawing2d::linear_gradient_mode enumeration element that specifies the orientation of the gradient. The orientation determines the starting and ending points of the gradient. For example, xtd::drawing::drawing2d::linear_gradient_mode::forward_diagonal specifies that the starting point is the upper-left corner of the rectangle and the ending point is the lower-right corner of the rectangle.

Member Function Documentation

◆ linear_colors() [1/3]

std::array< xtd::drawing::color, 2 > & xtd::drawing::drawing2d::linear_gradient_brush::linear_colors ( )
inline

Gets the starting and ending colors of the gradient.

Returns
An array of two xtd::drawing::color structures that represents the starting and ending colors of the gradient.

◆ linear_colors() [2/3]

const std::array< xtd::drawing::color, 2 > & xtd::drawing::drawing2d::linear_gradient_brush::linear_colors ( ) const
inline

Gets the starting and ending colors of the gradient.

Returns
An array of two xtd::drawing::color structures that represents the starting and ending colors of the gradient.

◆ linear_colors() [3/3]

xtd::drawing::drawing2d::linear_gradient_brush & xtd::drawing::drawing2d::linear_gradient_brush::linear_colors ( const std::array< xtd::drawing::color, 2 > &  linear_colors)

sets the starting and ending colors of the gradient.

Parameters
linear_colorsAn array of two xtd::drawing::color structures that represents the starting and ending colors of the gradient.
Returns
Current linear_gradient_brush instance.

◆ rectangle()

xtd::drawing::rectangle_f xtd::drawing::drawing2d::linear_gradient_brush::rectangle ( ) const

Gets a rectangular region that defines the starting and ending points of the gradient.

Returns
A xtd::drawing::rectangle_f structure that specifies the starting and ending points of the gradient.

The documentation for this class was generated from the following file: