xtd 0.2.0
Loading...
Searching...
No Matches
fill_rounded_rectangle.cpp

shows how to fill rounded rectangle in paint event using xtd::drawing::graphics::fill_rounded_rectangle.

Windows

macOS

Gnome

#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>
using namespace xtd;
using namespace xtd::drawing;
using namespace xtd::drawing::drawing_2d;
using namespace xtd::forms;
namespace fill_rounded_rectangle_example {
class form1 : public form {
public:
form1() {
text("Fill rounded rectangle example");
client_size({680, 340});
}
protected:
void on_paint(paint_event_args& e) override {
form::on_paint(e);
auto back_color = color::navy;
auto fore_color = color::white;
e.graphics().fill_rounded_rectangle(solid_brush {color::transparent}, rectangle {10, 10, 150, 150}, 20);
e.graphics().draw_rounded_rectangle(pen {fore_color, 4}, rectangle {10, 10, 150, 150}, 20);
e.graphics().fill_rounded_rectangle(solid_brush {back_color}, rectangle {180, 10, 150, 150}, 20);
e.graphics().draw_rounded_rectangle(pen {fore_color, 4}, rectangle {180, 10, 150, 150}, 20);
e.graphics().fill_rounded_rectangle(texture_brush {create_circle_texture(fore_color, back_color)}, rectangle {350, 10, 150, 150}, 20);
e.graphics().draw_rounded_rectangle(pen {fore_color, 4}, rectangle {350, 10, 150, 150}, 20);
e.graphics().fill_rounded_rectangle(hatch_brush {hatch_style::diagonal_brick, color::white, back_color}, rectangle {520, 10, 150, 150}, 20);
e.graphics().draw_rounded_rectangle(pen {color::white, 4}, rectangle(520, 10, 150, 150), 20);
e.graphics().fill_rounded_rectangle(conical_gradient_brush {point {85, 255}, back_color, fore_color, 0}, rectangle {10, 180, 150, 150}, 20);
e.graphics().draw_rounded_rectangle(pen {color::white, 4}, rectangle {10, 180, 150, 150}, 20);
e.graphics().fill_rounded_rectangle(linear_gradient_brush {rectangle {180, 180, 150, 150}, back_color, fore_color, 315}, rectangle {180, 180, 150, 150}, 20);
e.graphics().draw_rounded_rectangle(pen {color::white, 4}, rectangle {180, 180, 150, 150}, 20);
e.graphics().fill_rounded_rectangle(radial_gradient_brush {point {425, 255}, fore_color, back_color, 73}, rectangle {350, 180, 150, 150}, 20);
e.graphics().draw_rounded_rectangle(pen {color::white, 4}, rectangle {350, 180, 150, 150}, 20);
}
private:
auto create_circle_texture(const color& fore_color, const color& back_color)->image {
auto texture = bitmap {16, 16};
auto graphics = texture.create_graphics();
graphics.fill_ellipse(solid_brush {back_color}, 1, 1, texture.width() - 2, texture.height() - 2);
graphics.draw_ellipse(pen {fore_color, 2}, 1, 1, texture.width() - 2, texture.height() - 2);
return texture;
}
};
}
auto main()->int {
application::run(fill_rounded_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
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
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:52
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.h:28
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::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10