xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Classes | Public Member Functions | Static Public Member Functions | List of all members
xtd::drawing::graphics Class Reference

Defines an object used to draw lines and curves. This class cannot be inherited. More...

#include <graphics.h>

Public Member Functions

void clear (const color &color)
 Clears the entire drawing surface and fills it with the specified background color. More...
 
void draw_arc (const xtd::drawing::pen &pen, const xtd::drawing::rectangle &rect, float start_angle, float sweep_angle)
 Draws an arc representing a portion of an ellipse specified by a Rectangle structure. More...
 
void draw_arc (const xtd::drawing::pen &pen, const xtd::drawing::rectangle_f &rect, float start_angle, float sweep_angle)
 Draws an arc representing a portion of an ellipse specified by a Rectangle structure. More...
 
void draw_arc (const xtd::drawing::pen &pen, int32_t x, int32_t y, int32_t width, int32_t height, int32_t start_angle, int32_t sweep_angle)
 Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height. More...
 
void draw_arc (const xtd::drawing::pen &pen, float x, float y, float width, float height, float start_angle, float sweep_angle)
 Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height. More...
 
void draw_bezier (const xtd::drawing::pen &pen, const xtd::drawing::point &pt1, const xtd::drawing::point &pt2, const xtd::drawing::point &pt3, const xtd::drawing::point &pt4)
 Draws a Bézier spline defined by four Point structures. More...
 
void draw_bezier (const xtd::drawing::pen &pen, const xtd::drawing::point_f &pt1, const xtd::drawing::point_f &pt2, const xtd::drawing::point_f &pt3, const xtd::drawing::point_f &pt4)
 Draws a Bézier spline defined by four Point structures. More...
 
void draw_bezier (const pen &pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 Draws a Bézier spline defined by four ordered pairs of coordinates that represent points. More...
 
void draw_bezier (const pen &pen, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x3, int32_t y3, int32_t x4, int32_t y4)
 Draws a Bézier spline defined by four ordered pairs of coordinates that represent points. More...
 
void draw_ellipse (const xtd::drawing::pen &pen, const xtd::drawing::rectangle &rect)
 Draws an ellipse specified by a bounding xtd::drawing::rectangle structure. More...
 
void draw_ellipse (const xtd::drawing::pen &pen, const xtd::drawing::rectangle_f &rect)
 Draws an ellipse specified by a bounding xtd::drawing::rectangle_f structure. More...
 
void draw_ellipse (const xtd::drawing::pen &pen, int32_t x, int32_t y, int32_t width, int32_t height)
 Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width. More...
 
void draw_ellipse (const xtd::drawing::pen &pen, float x, float y, float width, float height)
 Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width. More...
 
void draw_image (const xtd::drawing::image &image, const xtd::drawing::rectangle &rect)
 
void draw_image (const xtd::drawing::image &image, const xtd::drawing::rectangle_f &rect)
 
void draw_image (const xtd::drawing::image &image, const xtd::drawing::point &point)
 
void draw_image (const xtd::drawing::image &image, const xtd::drawing::point_f &point)
 
void draw_image (const xtd::drawing::image &image, int32_t x, int32_t y, int32_t width, int32_t height)
 
void draw_image (const xtd::drawing::image &image, float x, float y, float width, float height)
 
void draw_image (const xtd::drawing::image &image, int32_t x, int32_t y)
 
void draw_image (const xtd::drawing::image &image, float x, float y)
 
void draw_line (const xtd::drawing::pen &pen, const xtd::drawing::point &p1, const point &p2)
 
void draw_line (const xtd::drawing::pen &pen, const xtd::drawing::point_f &p1, const point_f &p2)
 
void draw_line (const xtd::drawing::pen &pen, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
 
void draw_line (const xtd::drawing::pen &pen, float x1, float y1, float x2, float y2)
 
void draw_point (const xtd::drawing::pen &pen, const xtd::drawing::point &p)
 
void draw_point (const xtd::drawing::pen &pen, const xtd::drawing::point_f &p)
 
void draw_point (const xtd::drawing::pen &pen, int32_t x, int32_t y)
 
void draw_point (const xtd::drawing::pen &pen, float x, float y)
 
void draw_rectangle (const xtd::drawing::pen &pen, const xtd::drawing::rectangle &rect)
 
void draw_rectangle (const xtd::drawing::pen &pen, const xtd::drawing::rectangle_f &rect)
 
void draw_rectangle (const xtd::drawing::pen &pen, int32_t x, int32_t y, int32_t width, int32_t height)
 
void draw_rectangle (const xtd::drawing::pen &pen, float x, float y, float width, float height)
 
void draw_rounded_rectangle (const xtd::drawing::pen &pen, const xtd::drawing::rectangle &rect, int32_t radius)
 
void draw_rounded_rectangle (const xtd::drawing::pen &pen, const xtd::drawing::rectangle_f &rect, float radius)
 
void draw_rounded_rectangle (const xtd::drawing::pen &pen, int32_t x, int32_t y, int32_t width, int32_t height, int32_t radius)
 
void draw_rounded_rectangle (const xtd::drawing::pen &pen, float x, float y, float width, float height, float radius)
 
void draw_string (const std::string &text, const xtd::drawing::font &font, const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &layout_rectangle, const string_format &format)
 
void draw_string (const std::string &text, const xtd::drawing::font &font, const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &layout_rectangle)
 
void draw_string (const std::string &text, const xtd::drawing::font &font, const xtd::drawing::brush &brush, const xtd::drawing::point_f &point, const string_format &format)
 
void draw_string (const std::string &text, const xtd::drawing::font &font, const xtd::drawing::brush &brush, const xtd::drawing::point_f &point)
 
void draw_string (const std::string &text, const xtd::drawing::font &font, const xtd::drawing::brush &brush, float x, float y, const string_format &format)
 
void draw_string (const std::string &text, const xtd::drawing::font &font, const xtd::drawing::brush &brush, float x, float y)
 
void fill_ellipse (const xtd::drawing::brush &brush, const xtd::drawing::rectangle &rect)
 
void fill_ellipse (const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &rect)
 
void fill_ellipse (const xtd::drawing::brush &brush, int32_t x, int32_t y, int32_t width, int32_t height)
 
void fill_ellipse (const xtd::drawing::brush &brush, float x, float y, float width, float height)
 
void fill_pie (const xtd::drawing::brush &brush, const xtd::drawing::rectangle &rect, float start_angle, float sweep_angle)
 
void fill_pie (const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &rect, float start_angle, float sweep_angle)
 
void fill_pie (const xtd::drawing::brush &brush, int32_t x, int32_t y, int32_t width, int32_t height, int32_t start_angle, int32_t sweep_angle)
 
void fill_pie (const xtd::drawing::brush &brush, float x, float y, float width, float height, float start_angle, float sweep_angle)
 
void fill_rectangle (const xtd::drawing::brush &brush, const xtd::drawing::rectangle &rect)
 
void fill_rectangle (const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &rect)
 
void fill_rectangle (const xtd::drawing::brush &brush, int32_t x, int32_t y, int32_t width, int32_t height)
 
void fill_rectangle (const xtd::drawing::brush &brush, float x, float y, float width, float height)
 
void fill_rounded_rectangle (const xtd::drawing::brush &brush, const xtd::drawing::rectangle &rect, int32_t radius)
 
void fill_rounded_rectangle (const xtd::drawing::brush &brush, const xtd::drawing::rectangle_f &rect, float radius)
 
void fill_rounded_rectangle (const xtd::drawing::brush &brush, int32_t x, int32_t y, int32_t width, int32_t height, int32_t radius)
 
void fill_rounded_rectangle (const xtd::drawing::brush &brush, float x, float y, float width, float height, float radius)
 
intptr_t handle () const
 Gets the handle device context that the graphics is bound to. More...
 
size_f measure_string (const std::string &text, const xtd::drawing::font &font)
 
void rotate_transform (float angle)
 
std::string to_string () const noexcept override
 Returns a std::string that represents the current object. More...
 
void translate_clip (int32_t dx, int32_t dy)
 
void translate_clip (float dx, float dy)
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::shared_ptr< objectmemberwise_clone () const
 Gets the type of the current instance. More...
 

Static Public Member Functions

static graphics from_image (const xtd::drawing::image &image)
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

Detailed Description

Defines an object used to draw lines and curves. This class cannot be inherited.

Library
xtd.drawing
Examples:
colored_tab_pages.cpp, and fill_rectangle.cpp.

Member Function Documentation

◆ clear()

void xtd::drawing::graphics::clear ( const color color)

Clears the entire drawing surface and fills it with the specified background color.

Parameters
colorxtd::drawing::color structure that represents the background color of the drawing surface.

◆ draw_arc() [1/4]

void xtd::drawing::graphics::draw_arc ( const xtd::drawing::pen pen,
const xtd::drawing::rectangle rect,
float  start_angle,
float  sweep_angle 
)
inline

Draws an arc representing a portion of an ellipse specified by a Rectangle structure.

Parameters
penxtd::drawing::pen that determines the color, width, and style of the arc.
rectxtd::drawing::rectangle structure that defines the boundaries of the ellipse.
start_angleAngle in degrees measured clockwise from the x-axis to the starting point of the arc.
sweep_angleAngle in degrees measured clockwise from the start_angle parameter to ending point of the arc.
Remarks
This method draws an arc that is a portion of the perimeter of an ellipse. The ellipse is defined by the boundaries of a rectangle. The arc is the portion of the perimeter of the ellipse between the start_angle parameter and the start_angle + sweep_angle parameters.

◆ draw_arc() [2/4]

void xtd::drawing::graphics::draw_arc ( const xtd::drawing::pen pen,
const xtd::drawing::rectangle_f rect,
float  start_angle,
float  sweep_angle 
)
inline

Draws an arc representing a portion of an ellipse specified by a Rectangle structure.

Parameters
penxtd::drawing::pen that determines the color, width, and style of the arc.
rectxtd::drawing::rectangle_f structure that defines the boundaries of the ellipse.
start_angleAngle in degrees measured clockwise from the x-axis to the starting point of the arc.
sweep_angleAngle in degrees measured clockwise from the start_angle parameter to ending point of the arc.
Remarks
This method draws an arc that is a portion of the perimeter of an ellipse. The ellipse is defined by the boundaries of a rectangle. The arc is the portion of the perimeter of the ellipse between the start_angle parameter and the start_angle + sweep_angle parameters.

◆ draw_arc() [3/4]

void xtd::drawing::graphics::draw_arc ( const xtd::drawing::pen pen,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height,
int32_t  start_angle,
int32_t  sweep_angle 
)

Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.

Parameters
xThe x-coordinate of the upper-left corner of the rectangle that defines the ellipse.
yThe y-coordinate of the upper-left corner of the rectangle that defines the ellipse.
widthWidth of the rectangle that defines the ellipse.
heightHeight of the rectangle that defines the ellipse.
start_angleAngle in degrees measured clockwise from the x-axis to the starting point of the arc.
sweep_angleAngle in degrees measured clockwise from the start_angle parameter to ending point of the arc.
Remarks
This method draws an arc that is a portion of the perimeter of an ellipse. The ellipse is defined by the boundaries of a rectangle. The arc is the portion of the perimeter of the ellipse between the start_angle parameter and the start_angle + sweep_angle parameters.

◆ draw_arc() [4/4]

void xtd::drawing::graphics::draw_arc ( const xtd::drawing::pen pen,
float  x,
float  y,
float  width,
float  height,
float  start_angle,
float  sweep_angle 
)
inline

Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height.

Parameters
xThe x-coordinate of the upper-left corner of the rectangle that defines the ellipse.
yThe y-coordinate of the upper-left corner of the rectangle that defines the ellipse.
widthWidth of the rectangle that defines the ellipse.
heightHeight of the rectangle that defines the ellipse.
start_angleAngle in degrees measured clockwise from the x-axis to the starting point of the arc.
sweep_angleAngle in degrees measured clockwise from the start_angle parameter to ending point of the arc.
Remarks
This method draws an arc that is a portion of the perimeter of an ellipse. The ellipse is defined by the boundaries of a rectangle. The arc is the portion of the perimeter of the ellipse between the start_angle parameter and the start_angle + sweep_angle parameters.

◆ draw_bezier() [1/4]

void xtd::drawing::graphics::draw_bezier ( const xtd::drawing::pen pen,
const xtd::drawing::point pt1,
const xtd::drawing::point pt2,
const xtd::drawing::point pt3,
const xtd::drawing::point pt4 
)
inline

Draws a Bézier spline defined by four Point structures.

Parameters
penxtd::drawing::pen structure that determines the color, width, and style of the curve.
pt1xtd::drawing::point structure that represents the starting point of the curve.
pt2xtd::drawing::point structure that represents the first control point for the curve.
pt3xtd::drawing::point structure that represents the second control point for the curve.
pt4xtd::drawing::point structure that represents the ending point of the curve.
Remarks
The Bézier curve is drawn from the first point to the fourth point. The second and third points are control points that determine the shape of the curve.

◆ draw_bezier() [2/4]

void xtd::drawing::graphics::draw_bezier ( const xtd::drawing::pen pen,
const xtd::drawing::point_f pt1,
const xtd::drawing::point_f pt2,
const xtd::drawing::point_f pt3,
const xtd::drawing::point_f pt4 
)
inline

Draws a Bézier spline defined by four Point structures.

Parameters
penxtd::drawing::pen structure that determines the color, width, and style of the curve.
pt1xtd::drawing::point structure that represents the starting point of the curve.
pt2xtd::drawing::point structure that represents the first control point for the curve.
pt3xtd::drawing::point structure that represents the second control point for the curve.
pt4xtd::drawing::point structure that represents the ending point of the curve.
Remarks
The Bézier curve is drawn from the first point to the fourth point. The second and third points are control points that determine the shape of the curve.

◆ draw_bezier() [3/4]

void xtd::drawing::graphics::draw_bezier ( const pen pen,
float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
float  x4,
float  y4 
)
inline

Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.

Parameters
penxtd::drawing::pen structure that determines the color, width, and style of the curve.
x1The x-coordinate of the starting point of the curve.
y1The y-coordinate of the starting point of the curve.
x2The x-coordinate of the first control point of the curve.
y2The y-coordinate of the first control point of the curve.
x3The x-coordinate of the second control point of the curve.
y3The y-coordinate of the second control point of the curve.
x4The x-coordinate of the ending point of the curve.
y4The y-coordinate of the ending point of the curve.
Remarks
The Bézier curve is drawn from the first point to the fourth point. The second and third points are control points that determine the shape of the curve.

◆ draw_bezier() [4/4]

void xtd::drawing::graphics::draw_bezier ( const pen pen,
int32_t  x1,
int32_t  y1,
int32_t  x2,
int32_t  y2,
int32_t  x3,
int32_t  y3,
int32_t  x4,
int32_t  y4 
)

Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.

Parameters
penxtd::drawing::pen structure that determines the color, width, and style of the curve.
x1The x-coordinate of the starting point of the curve.
y1The y-coordinate of the starting point of the curve.
x2The x-coordinate of the first control point of the curve.
y2The y-coordinate of the first control point of the curve.
x3The x-coordinate of the second control point of the curve.
y3The y-coordinate of the second control point of the curve.
x4The x-coordinate of the ending point of the curve.
y4The y-coordinate of the ending point of the curve.
Remarks
The Bézier curve is drawn from the first point to the fourth point. The second and third points are control points that determine the shape of the curve.

◆ draw_ellipse() [1/4]

void xtd::drawing::graphics::draw_ellipse ( const xtd::drawing::pen pen,
const xtd::drawing::rectangle rect 
)
inline

Draws an ellipse specified by a bounding xtd::drawing::rectangle structure.

Parameters
penxtd::drawing::pen that determines the color, width, and style of the ellipse.
rectxtd::drawing::rectangle structure that defines the boundaries of the ellipse.
Remarks
This method draws an ellipse that is defined by the bounding rectangle specified by the rect parameter.
Examples:
fill_rectangle.cpp.

◆ draw_ellipse() [2/4]

void xtd::drawing::graphics::draw_ellipse ( const xtd::drawing::pen pen,
const xtd::drawing::rectangle_f rect 
)
inline

Draws an ellipse specified by a bounding xtd::drawing::rectangle_f structure.

Parameters
penxtd::drawing::pen that determines the color, width, and style of the ellipse.
rectxtd::drawing::rectangle_f structure that defines the boundaries of the ellipse.
Remarks
This method draws an ellipse that is defined by the bounding rectangle specified by the rect parameter.

◆ draw_ellipse() [3/4]

void xtd::drawing::graphics::draw_ellipse ( const xtd::drawing::pen pen,
int32_t  x,
int32_t  y,
int32_t  width,
int32_t  height 
)

Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.

Parameters
penxtd::drawing::pen that determines the color, width, and style of the ellipse.
xThe x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.
yThe y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.
widthWidth of the bounding rectangle that defines the ellipse.
heightHeight of the bounding rectangle that defines the ellipse.
Remarks
This method draws an ellipse that is defined by the bounding rectangle described by the x, y, width, and height parameters.

◆ draw_ellipse() [4/4]

void xtd::drawing::graphics::draw_ellipse ( const xtd::drawing::pen pen,
float  x,
float  y,
float  width,
float  height 
)
inline

Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width.

Parameters
penxtd::drawing::pen that determines the color, width, and style of the ellipse.
xThe x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.
yThe y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.
widthWidth of the bounding rectangle that defines the ellipse.
heightHeight of the bounding rectangle that defines the ellipse.
Remarks
This method draws an ellipse that is defined by the bounding rectangle described by the x, y, width, and height parameters.

◆ handle()

intptr_t xtd::drawing::graphics::handle ( ) const
inline

Gets the handle device context that the graphics is bound to.

Returns
An intptr_t that contains the handle device context of the graphics.

◆ to_string()

std::string xtd::drawing::graphics::to_string ( ) const
inlineoverridevirtualnoexcept

Returns a std::string that represents the current object.

Returns
A string that represents the current object.
Examples
The following code example demonstrates what to_string returns.

Reimplemented from xtd::object.


The documentation for this class was generated from the following file: