#include <xtd/drawing/drawing_2d/conical_gradient_brush>
#include <xtd/drawing/drawing_2d/hatch_brush>
#include <xtd/drawing/drawing_2d/linear_gradient_brush>
#include <xtd/drawing/drawing_2d/radial_gradient_brush>
#include <xtd/drawing/solid_brush>
#include <xtd/drawing/texture_brush>
#include <xtd/forms/application>
#include <xtd/forms/form>
namespace fill_rectangle_example {
class form1 :
public form {
public:
form1() {
text("Fill rectangle example");
client_size({680, 340});
}
protected:
form::on_paint(e);
auto back_color = color::navy;
auto fore_color = color::white;
e.graphics().draw_rectangle(
pen {fore_color, 4},
rectangle {10, 10, 150, 150});
e.graphics().draw_rectangle(
pen {fore_color, 4},
rectangle {180, 10, 150, 150});
e.graphics().fill_rectangle(
texture_brush {create_circle_texture(fore_color, back_color)},
rectangle {350, 10, 150, 150});
e.graphics().draw_rectangle(
pen {fore_color, 4},
rectangle {350, 10, 150, 150});
e.graphics().fill_rectangle(
hatch_brush {hatch_style::diagonal_brick, color::white, back_color},
rectangle {520, 10, 150, 150});
e.graphics().draw_rectangle(
pen {color::white, 4},
rectangle {520, 10, 150, 150});
e.graphics().draw_rectangle(
pen {color::white, 4},
rectangle {10, 180, 150, 150});
e.graphics().fill_rectangle(
linear_gradient_brush {
rectangle {180, 180, 150, 150}, back_color, fore_color, 315},
rectangle {180, 180, 150, 150});
e.graphics().draw_rectangle(
pen {color::white, 4},
rectangle {180, 180, 150, 150});
e.graphics().draw_rectangle(
pen {color::white, 4},
rectangle {350, 180, 150, 150});
}
private:
auto create_circle_texture(
const color& fore_color,
const color& back_color)->image {
auto texture =
bitmap {16, 16};
auto graphics = texture.create_graphics();
return texture;
}
};
}
auto main() -> int {
application::run(fill_rectangle_example::form1 {});
}
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.h:26
Represents an ARGB (alpha, red, green, blue) color.
Definition color.h:49
Encapsulates a xtd::drawing::brush with a conical gradient. This class cannot be inherited.
Definition conical_gradient_brush.h:35
Defines a rectangular xtd::drawing::brush with a hatch style, a foreground color, and a background co...
Definition hatch_brush.h:32
Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.
Definition linear_gradient_brush.h:31
Encapsulates a xtd::drawing::brush with a radial gradient. This class cannot be inherited.
Definition radial_gradient_brush.h:30
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.h:70
void fill_ellipse(const xtd::drawing::brush &brush, const xtd::drawing::rectangle &rect)
Fills the interior of an ellipse defined by a bounding rectangle specified by a xtd::drawing::rectang...
void draw_ellipse(const xtd::drawing::pen &pen, const xtd::drawing::rectangle &rect)
Draws an ellipse specified by a bounding xtd::drawing::rectangle structure.
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition pen.h:35
float width() const noexcept
Gets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for draw...
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.h:54
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.h:44
Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes,...
Definition solid_brush.h:30
Each property of the xtd::drawing::texture_brush class is a xtd::drawing::brush object that uses an i...
Definition texture_brush.h:29
The xtd::drawing::drawing_2d namespace provides advanced two-dimensional and vector graphics function...
Definition compositing_mode.h:12
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.h:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10