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

shows how to fill ellipse in paint event using xtd::drawing::graphics::fill_ellipse.

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_ellipse_example {
class form1 : public form {
public:
form1() {
text("Fill ellipse 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_ellipse(solid_brush {color::transparent}, rectangle {10, 10, 150, 150});
e.graphics().draw_ellipse(pen {fore_color, 4}, rectangle {10, 10, 150, 150});
e.graphics().fill_ellipse(solid_brush {back_color}, rectangle {180, 10, 150, 150});
e.graphics().draw_ellipse(pen {fore_color, 4}, rectangle {180, 10, 150, 150});
e.graphics().fill_ellipse(texture_brush {create_circle_texture(fore_color, back_color)}, rectangle {350, 10, 150, 150});
e.graphics().draw_ellipse(pen {fore_color, 4}, rectangle {350, 10, 150, 150});
e.graphics().fill_ellipse(hatch_brush {hatch_style::diagonal_brick, color::white, back_color}, rectangle {520, 10, 150, 150});
e.graphics().draw_ellipse(pen {color::white, 4}, rectangle {520, 10, 150, 150});
e.graphics().fill_ellipse(conical_gradient_brush {point {85, 255}, back_color, fore_color, 0}, rectangle {10, 180, 150, 150});
e.graphics().draw_ellipse(pen {color::white, 4}, rectangle {10, 180, 150, 150});
e.graphics().fill_ellipse(linear_gradient_brush {rectangle {180, 180, 150, 150}, back_color, fore_color, 315}, rectangle {180, 180, 150, 150});
e.graphics().draw_ellipse(pen {color::white, 4}, rectangle {180, 180, 150, 150});
e.graphics().fill_ellipse(radial_gradient_brush {point {425, 255}, fore_color, back_color, 73}, rectangle {350, 180, 150, 150});
e.graphics().draw_ellipse(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();
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_ellipse_example::form1 {});
}
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.hpp:26
Represents an ARGB (alpha, red, green, blue) color.
Definition color.hpp:49
Encapsulates a xtd::drawing::brush with a conical gradient. This class cannot be inherited.
Definition conical_gradient_brush.hpp:35
Defines a rectangular xtd::drawing::brush with a hatch style, a foreground color, and a background co...
Definition hatch_brush.hpp:32
Encapsulates a xtd::drawing::brush with a linear gradient. This class cannot be inherited.
Definition linear_gradient_brush.hpp:31
Encapsulates a xtd::drawing::brush with a radial gradient. This class cannot be inherited.
Definition radial_gradient_brush.hpp:30
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition graphics.hpp: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.hpp:35
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 integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44
Defines a xtd::drawing::brush of a single color. Brushes are used to fill graphics shapes,...
Definition solid_brush.hpp:30
Each property of the xtd::drawing::texture_brush class is a xtd::drawing::brush object that uses an i...
Definition texture_brush.hpp:29
Represents a window or dialog box that makes up an application's user interface.
Definition form.hpp:54
Provides data for the xtd::forms::control::paint event.
Definition paint_event_args.hpp:30
The xtd::drawing::drawing_2d namespace provides advanced two-dimensional and vector graphics function...
Definition compositing_mode.hpp:12
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:11
The xtd::forms namespace contains classes for creating Windows-based applications that take full adva...
Definition xtd_about_box.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10