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

demonstrates paint event with form.

Windows

macOS

Gnome

#include <xtd/drawing/drawing_2d/linear_gradient_brush>
#include <xtd/drawing/drawing_2d/radial_gradient_brush>
#include <xtd/drawing/brushes>
#include <xtd/forms/application>
#include <xtd/forms/form>
using namespace xtd;
using namespace xtd::collections::generic;
using namespace xtd::drawing;
using namespace xtd::drawing::drawing_2d;
using namespace xtd::forms;
namespace form_paint_example {
class form1 : public form {
public:
form1() {
text("Paint example");
client_size({640, 480});
minimum_client_size({350, 320});
paint += [](object & sender, paint_event_args & e) {
e.graphics().clear(color::cyan);
e.graphics().draw_string("Drawing with graphics", drawing::font("Arial", 34, font_style::regular), brushes::dark_cyan(), {20.0f, 20.0f, e.clip_rectangle().width() - 180.0f, e.clip_rectangle().height() - 40.0f});
e.graphics().fill_ellipse(radial_gradient_brush(point {e.clip_rectangle().width() - 100, 100}, color::white, color::yellow, 75), e.clip_rectangle().width() - 150, 50, 100, 100);
e.graphics().draw_ellipse(pen(color::yellow_green, 2), e.clip_rectangle().width() - 150, 50, 100, 100);
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 {});
}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.h:71
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 a particular format for text, including font face, size, and style attributes....
Definition font.h:45
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
Represents a window or dialog box that makes up an application's user interface.
Definition form.h:54
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.h:30
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.h:15
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 brush.h:18
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