#include <xtd/xtd>
namespace examples {
class form1 : public form {
public:
form1() {
text("Fill rectangle example");
client_size({340, 230});
}
protected:
void on_paint(paint_event_args& e) override {
e.graphics().fill_rectangle(solid_brush(
color::red), 120, 10, 100, 100);
e.graphics().fill_rectangle(linear_gradient_brush(rectangle(230, 10, 100, 100),
color::green,
color::white,
linear_gradient_mode::horizontal), 230, 10, 100, 100);
e.graphics().fill_rectangle(texture_brush(create_circle_texture(
color::yellow)), 120, 120, 100, 100);
form::on_paint(e);
}
private:
image create_circle_texture(const color& color) {
auto texture = bitmap(16, 16);
auto graphics = texture.create_graphics();
graphics.fill_ellipse(solid_brush(color), 0, 0, texture.width() - 1, texture.height() - 1);
graphics.draw_ellipse(
pens::black(), 0, 0, texture.width() - 1, texture.height() - 1);
return texture;
}
};
}
int main() {
application::run(examples::form1());
}
static xtd::drawing::solid_brush transparent()
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.h:465
static const xtd::drawing::color white
Gets a system-defined color that has an ARGB value of 0xFFFFFFFF. This field is constant.
Definition: color.h:459
static const xtd::drawing::color green
Gets a system-defined color that has an ARGB value of 0xFF008000. This field is constant.
Definition: color.h:201
static const xtd::drawing::color red
Gets a system-defined color that has an ARGB value of 0xFFFF0000. This field is constant.
Definition: color.h:390
static const xtd::drawing::color blue
Gets a system-defined color that has an ARGB value of 0xFF0000FF. This field is constant.
Definition: color.h:75
hatch_brush()
Initializes a new instance of the hatch_brush class.
static xtd::drawing::pen black()
A system-defined pen object with a width of 1.
@ horizontal
Specifies a gradient from left to right.
@ diagonal_brick
Specifies a hatch that has the appearance of layered bricks that slant to the left from top points to...
The xtd::.drawing::drawing2d namespace provides advanced two-dimensional and vector graphics function...
Definition: hatch_brush.h:19
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition: bitmap.h:11
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17