#include <xtd/diagnostics/process>
#include <xtd/drawing/drawing_2d/linear_gradient_brush>
#include <xtd/drawing/drawing_2d/radial_gradient_brush>
#include <xtd/drawing/bitmap>
#include <xtd/drawing/brushes>
#include <xtd/drawing/graphics>
#include <xtd/drawing/system_fonts>
#include <xtd/io/path>
auto main() -> int {
auto drawing_bitmap =
bitmap {640, 480};
auto graphics = graphics::from_image(drawing_bitmap);
graphics.
draw_string(
"Drawing with graphics",
drawing::font(
"Arial", 34, font_style::regular),
drawing_2d::linear_gradient_brush(
rectangle_f {20.0f, 20.0f, drawing_bitmap.
width() - 180.0f, drawing_bitmap.height() - 40.0f}, color::navy, color::light_blue), {20.0f, 20.0f, drawing_bitmap.width() - 180.0f, drawing_bitmap.height() - 40.0f});
graphics.
fill_rectangle(brushes::spring_green(), 0, drawing_bitmap.height() - 100, drawing_bitmap.width(), 100);
graphics.
fill_rectangle(brushes::red(), drawing_bitmap.width() / 2 - 140, drawing_bitmap.height() - 180, 280, 150);
graphics.
fill_rectangle(brushes::black(), drawing_bitmap.width() / 2 - 30, drawing_bitmap.height() - 140, 60, 110);
graphics.
fill_rectangle(brushes::white(), drawing_bitmap.width() / 2 - 120, drawing_bitmap.height() - 140, 70, 60);
graphics.
fill_rectangle(brushes::white(), drawing_bitmap.width() / 2 + 50, drawing_bitmap.height() - 140, 70, 60);
graphics.
fill_polygon(
linear_gradient_brush {
rectangle {drawing_bitmap.
width() / 2 - 160, drawing_bitmap.height() - 300, 320, 120}, color::brown, color::sandy_brown, linear_gradient_mode::backward_diagonal},
list<point> {{drawing_bitmap.width() / 2, drawing_bitmap.height() - 300}, {drawing_bitmap.width() / 2 + 160, drawing_bitmap.height() - 180}, {drawing_bitmap.width() / 2 - 160, drawing_bitmap.height() - 180},});
drawing_bitmap.save(path::combine(path::get_temp_path(), "graphics.png"));
process::start(path::combine(path::get_temp_path(), "graphics.png"));
}
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
Definition list.hpp:80
Encapsulates a GDI+ bitmap, which consists of the pixel data for a graphics image and its attributes....
Definition bitmap.hpp:26
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 graphics.hpp:67
void fill_polygon(const xtd::drawing::brush &brush, const xtd::array< xtd::drawing::point > &points)
Fills the interior of a polygon defined by an array of points specified by xtd::drawing::point struct...
void clear(const color &color)
Clears the entire drawing surface and fills it with the specified background color.
void draw_string(const xtd::string &s, const xtd::drawing::font &font, const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &layout_rectangle)
Draws the specified text string at the specified rectangle with the specified xtd::drawing::brush and...
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 fill_rectangle(const xtd::drawing::brush &brush, const xtd::drawing::rectangle &rect)
Fills the interior of a rectangle specified by a xtd::drawing::rectangle structure.
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:32
float width() const noexcept
Gets the width of this xtd::drawing::pen, in units of the xtd::drawing::graphics object used for draw...
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
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:10
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
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
float width
Gets or sets the width of this xtd::drawing::rectangle_f structure.
Definition rectangle_f.hpp:81
Stores a set of four integers that represent the location and size of a rectangle.
Definition rectangle.hpp:44
int32 width
Gets or sets the width of this xtd::drawing::rectangle structure.
Definition rectangle.hpp:92