xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
linear_gradient_brush.h
Go to the documentation of this file.
1
4#pragma once
5#include <array>
6#include "../../drawing_export.h"
7#include "../brush.h"
8#include "../color.h"
9#include "../point.h"
10#include "../rectangle.h"
12
14namespace xtd {
16 namespace drawing {
18 namespace drawing2d {
29 public:
37 linear_gradient_brush(const xtd::drawing::point& point1, const xtd::drawing::point& point2, const xtd::drawing::color& color1, const xtd::drawing::color& color2) {
38 data_->point1_ = point1;
39 data_->point2_ = point2;
40 data_->linear_colors_ = {color1, color2};
41 recreate_handle();
42 }
49 data_->point1_ = point1;
50 data_->point2_ = point2;
51 data_->linear_colors_ = {color1, color2};
52 recreate_handle();
53 }
58 linear_gradient_brush(const xtd::drawing::rectangle_f& rect, const xtd::drawing::color& color1, const xtd::drawing::color& color2) : linear_gradient_brush(rect, color1, color2, xtd::drawing::drawing2d::linear_gradient_mode::horizontal) {}
65 data_->point1_ = rect.location();
66 data_->point2_ = xtd::drawing::point_f(rect.right(), rect.bottom());
70 auto x = data_->point1_.x();
71 data_->point1_.x(data_->point2_.x());
72 data_->point2_.x(x);
73 }
74 data_->linear_colors_ = {color1, color2};
75 recreate_handle();
76 }
81 linear_gradient_brush(const xtd::drawing::rectangle& rect, const xtd::drawing::color& color1, const xtd::drawing::color& color2) : linear_gradient_brush(rect, color1, color2, xtd::drawing::drawing2d::linear_gradient_mode::horizontal) {}
88 data_->point1_ = rect.location();
89 data_->point2_ = xtd::drawing::point(rect.right(), rect.bottom());
91 if (linear_gradient_mode == xtd::drawing::drawing2d::linear_gradient_mode::vertical) data_->point2_.x(data_->point1_.x());
93 auto x = data_->point1_.x();
94 data_->point1_.x(data_->point2_.x());
95 data_->point2_.x(x);
96 }
97 data_->linear_colors_ = {color1, color2};
98 recreate_handle();
99 }
100
103 linear_gradient_brush& operator=(const linear_gradient_brush& value);
104 bool operator==(const linear_gradient_brush& value) const {return data_->point1_ == value.data_->point1_ && data_->point2_ == value.data_->point2_ && data_->linear_colors_[0] == value.data_->linear_colors_[0] && data_->linear_colors_[1] == value.data_->linear_colors_[1];}
105 bool operator!=(const linear_gradient_brush& value) const {return !operator==(value);}
107
110 const std::array<xtd::drawing::color, 2>& linear_colors() const {return data_->linear_colors_;}
113 std::array<xtd::drawing::color, 2>& linear_colors() {return data_->linear_colors_;}
117 xtd::drawing::drawing2d::linear_gradient_brush& linear_colors(const std::array<xtd::drawing::color, 2>& linear_colors);
118
122
123 private:
124 void recreate_handle();
125 struct data {
126 xtd::drawing::point_f point1_;
127 xtd::drawing::point_f point2_;
128 std::array<xtd::drawing::color, 2> linear_colors_;
129 };
130 std::shared_ptr<data> data_ = std::make_shared<data>();
131 };
132 }
133 }
134}
Defines objects used to fill the interiors of graphical shapes such as rectangles,...
Definition: brush.h:27
Represents an ARGB (alpha, red, green, blue) color.
Definition: color.h:39
Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.
Definition: linear_gradient_brush.h:28
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.
Definition: linear_gradient_brush.h:37
xtd::drawing::rectangle_f rectangle() const
Gets a rectangular region that defines the starting and ending points of the gradient.
const std::array< xtd::drawing::color, 2 > & linear_colors() const
Gets the starting and ending colors of the gradient.
Definition: linear_gradient_brush.h:110
linear_gradient_brush()
Initializes a new instance of the linear_gradient_brush class.
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,...
Definition: linear_gradient_brush.h:87
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.
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,...
Definition: linear_gradient_brush.h:64
std::array< xtd::drawing::color, 2 > & linear_colors()
Gets the starting and ending colors of the gradient.
Definition: linear_gradient_brush.h:113
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.
Definition: linear_gradient_brush.h:48
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...
Definition: linear_gradient_brush.h:81
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...
Definition: linear_gradient_brush.h:58
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:26
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:48
Stores a set of four floating-points that represent the location and size of a rectangle.
Definition: rectangle_f.h:28
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:25
#define drawing_export_
Define shared library export.
Definition: drawing_export.h:13
@ x
The X key.
linear_gradient_mode
Specifies the direction of a linear gradient.
Definition: linear_gradient_mode.h:19
@ horizontal
Specifies a gradient from left to right.
@ backward_diagonal
Specifies a gradient from upper right to lower left.
@ vertical
Specifies a gradient from top to bottom.
@ horizontal
A pattern of horizontal lines.
Contains xtd::drawing::drawing2d::linear_gradient_mode enum class.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17