demonstrates paint event with form.
#include <xtd/xtd>
namespace form_paint_example {
class form1 : public form {
public:
form1() {
client_size({640, 480});
minimum_client_size({350, 320});
paint +=
delegate_(
object & sender, paint_event_args &
e) {
e.graphics().draw_string(
"Drawing with graphics",
drawing::font(
"Arial", 34,
font_style::regular),
linear_gradient_brush(
rectangle_f {20.0f, 20.0f,
e.clip_rectangle().width - 180.0f,
e.clip_rectangle().height - 40.0f},
color::navy,
color::light_blue), {20.0f, 20.0f,
e.clip_rectangle().width - 180.0f,
e.clip_rectangle().height - 40.0f});
e.graphics().fill_rectangle(
brushes::spring_green(), 0,
e.clip_rectangle().height - 100,
e.clip_rectangle().width, 100);
e.graphics().fill_rectangle(
brushes::red(),
e.clip_rectangle().width / 2 - 140,
e.clip_rectangle().height - 180, 280, 150);
e.graphics().fill_rectangle(
brushes::black(),
e.clip_rectangle().width / 2 - 30,
e.clip_rectangle().height - 140, 60, 110);
e.graphics().fill_rectangle(
brushes::white(),
e.clip_rectangle().width / 2 - 120,
e.clip_rectangle().height - 140, 70, 60);
e.graphics().fill_rectangle(
brushes::white(),
e.clip_rectangle().width / 2 + 50,
e.clip_rectangle().height - 140, 70, 60);
e.graphics().fill_polygon(
linear_gradient_brush(
rectangle {
e.clip_rectangle().width / 2 - 160,
e.clip_rectangle().height - 300, 320, 120},
color::brown,
color::sandy_brown,
linear_gradient_mode::backward_diagonal), list<point> {{
e.clip_rectangle().width / 2,
e.clip_rectangle().height - 300}, {
e.clip_rectangle().width / 2 + 160,
e.clip_rectangle().height - 180}, {
e.clip_rectangle().width / 2 - 160,
e.clip_rectangle().height - 180},});
};
}
};
}
auto main() -> int {
application::run(form_paint_example::form1 {});
}
static xtd::drawing::solid_brush white()
A system-defined brush object.
static xtd::drawing::solid_brush spring_green()
A system-defined brush object.
static xtd::drawing::solid_brush black()
A system-defined brush object.
static xtd::drawing::solid_brush red()
A system-defined brush object.
static const xtd::drawing::color yellow
Gets a system-defined color that has an ARGB value of 0xFFFFFF00. This field is constant.
Definition color.hpp:476
static const xtd::drawing::color white
Gets a system-defined color that has an ARGB value of 0xFFFFFFFF. This field is constant.
Definition color.hpp:470
static const xtd::drawing::color light_blue
Gets a system-defined color that has an ARGB value of 0xFFADD8E6. This field is constant.
Definition color.hpp:248
static const xtd::drawing::color yellow_green
Gets a system-defined color that has an ARGB value of 0xFF9ACD32. This field is constant.
Definition color.hpp:479
static const xtd::drawing::color navy
Gets a system-defined color that has an ARGB value of 0xFF000080. This field is constant.
Definition color.hpp:344
static const xtd::drawing::color sandy_brown
Gets a system-defined color that has an ARGB value of 0xFFF4A460. This field is constant.
Definition color.hpp:416
static const xtd::drawing::color brown
Gets a system-defined color that has an ARGB value of 0xFFA52A2A. This field is constant.
Definition color.hpp:92
static const xtd::drawing::color cyan
Gets a system-defined color that has an ARGB value of 0xFF00FFFF. This field is constant.
Definition color.hpp:119
Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.
Definition linear_gradient_brush.hpp:30
Encapsulates a xtd::drawing::brush with a radial gradient. This class cannot be inherited.
Definition radial_gradient_brush.hpp:29
Defines a particular format for text, including font face, size, and style attributes....
Definition font.hpp:45
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition pen.hpp:32
@ regular
Normal text.
Definition font_style.hpp:19
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:900
@ e
The E key.
Definition console_key.hpp:96
@ backward_diagonal
Specifies a gradient from upper right to lower left.
Definition linear_gradient_mode.hpp:27
The xtd::drawing::drawing_2d namespace provides advanced two-dimensional and vector graphics function...
Definition compositing_mode.hpp:12
The xtd::drawing::text namespace provides advanced GDI+ typography functionality.
Definition font_collection.hpp:14
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54
Stores a set of four floating-point numbers that represent the location and size of a rectangle....
Definition rectangle_f.hpp:34
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44