Draw on Canvas using SVG-like path commands.
More...
Go to the source code of this file.
|
int | Canvas_path (const char *path, char ch) |
| Draws a path on the canvas using the specified path string.
|
Draw on Canvas using SVG-like path commands.
- Author
- Gregory Mitchell (me@gm.nosp@m.itch.nosp@m.215.x.nosp@m.yz)
- Version
- 0.2.0
- Date
- 2025-04-25
- Copyright
- Copyright (c) 2025
◆ CMDFX_PATH_COMMAND_ARC_ABSOLUTE
#define CMDFX_PATH_COMMAND_ARC_ABSOLUTE 'A' |
Draws an elliptical arc from the current point to the specified coordinates.
- Parameters
-
rx | The x radius of the ellipse |
ry | The y radius of the ellipse |
x_axis_rotation | The rotation of the ellipse in degrees |
large_arc_flag | A flag indicating whether to use the large arc |
sweep_flag | A flag indicating whether to use the positive angle |
x2 | The x coordinate of the end point |
y2 | The y coordinate of the end point |
◆ CMDFX_PATH_COMMAND_ARC_RELATIVE
#define CMDFX_PATH_COMMAND_ARC_RELATIVE 'a' |
Draws an elliptical arc from the current point to the specified coordinates relative to the current point.
- Parameters
-
rx | The x radius of the ellipse |
ry | The y radius of the ellipse |
x_axis_rotation | The rotation of the ellipse in degrees |
large_arc_flag | A flag indicating whether to use the large arc |
sweep_flag | A flag indicating whether to use the positive angle |
dx2 | The x coordinate of the end point relative to the current point |
dy2 | The y coordinate of the end point relative to the current point |
◆ CMDFX_PATH_COMMAND_CUBIC_ABSOLUTE
#define CMDFX_PATH_COMMAND_CUBIC_ABSOLUTE 'C' |
Draws a cubic Bezier curve from the current point to the specified coordinates.
- Parameters
-
x1 | The x coordinate of the first control point |
y1 | The y coordinate of the first control point |
x2 | The x coordinate of the second control point |
y2 | The y coordinate of the second control point |
x3 | The x coordinate of the end point |
y3 | The y coordinate of the end point |
◆ CMDFX_PATH_COMMAND_CUBIC_RELATIVE
#define CMDFX_PATH_COMMAND_CUBIC_RELATIVE 'c' |
Draws a cubic Bezier curve from the current point to the specified coordinates relative to the current point.
- Parameters
-
dx1 | The x coordinate of the first control point relative to the current point |
dy1 | The y coordinate of the first control point relative to the current point |
dx2 | The x coordinate of the second control point relative to the current point |
dy2 | The y coordinate of the second control point relative to the current point |
dx3 | The x coordinate of the end point relative to the current point |
dy3 | The y coordinate of the end point relative to the current point |
◆ CMDFX_PATH_COMMAND_ELLIPSE_ABSOLUTE
#define CMDFX_PATH_COMMAND_ELLIPSE_ABSOLUTE 'E' |
Draws an ellipse with the specified coordinates.
- Parameters
-
cx | The x coordinate of the center of the ellipse |
cy | The y coordinate of the center of the ellipse |
rx | The x radius of the ellipse |
ry | The y radius of the ellipse |
x_axis_rotation | The rotation of the ellipse in degrees |
◆ CMDFX_PATH_COMMAND_ELLIPSE_RELATIVE
#define CMDFX_PATH_COMMAND_ELLIPSE_RELATIVE 'e' |
Draws an ellipse with the specified coordinates relative to the current point.
- Parameters
-
dx | The x coordinate of the center of the ellipse relative to the current point |
dy | The y coordinate of the center of the ellipse relative to the current point |
rx | The x radius of the ellipse |
ry | The y radius of the ellipse |
x_axis_rotation | The rotation of the ellipse in degrees |
◆ CMDFX_PATH_COMMAND_HLINETO_ABSOLUTE
#define CMDFX_PATH_COMMAND_HLINETO_ABSOLUTE 'H' |
Draws a horizontal line from the current point to the specified x coordinate.
- Parameters
-
x | The x coordinate of the point |
◆ CMDFX_PATH_COMMAND_HLINETO_RELATIVE
#define CMDFX_PATH_COMMAND_HLINETO_RELATIVE 'h' |
Draws a horizontal line from the current point to the specified x coordinate relative to the current point.
- Parameters
-
dx | The x coordinate of the point relative to the current point |
◆ CMDFX_PATH_COMMAND_LINETO_ABSOLUTE
#define CMDFX_PATH_COMMAND_LINETO_ABSOLUTE 'L' |
Draws a line from the current point to the specified coordinates.
- Parameters
-
x | The x coordinate of the point |
y | The y coordinate of the point |
◆ CMDFX_PATH_COMMAND_LINETO_RELATIVE
#define CMDFX_PATH_COMMAND_LINETO_RELATIVE 'l' |
Draws a line from the current point to the specified coordinates relative to the current point.
- Parameters
-
dx | The x coordinate of the point relative to the current point |
dy | The y coordinate of the point relative to the current point |
◆ CMDFX_PATH_COMMAND_MOVETO_ABSOLUTE
#define CMDFX_PATH_COMMAND_MOVETO_ABSOLUTE 'M' |
Moves the current point to the specified coordinates.
- Parameters
-
x | The x coordinate of the point |
y | The y coordinate of the point |
◆ CMDFX_PATH_COMMAND_MOVETO_RELATIVE
#define CMDFX_PATH_COMMAND_MOVETO_RELATIVE 'm' |
Moves the current point to the specified coordinates relative to the current point.
- Parameters
-
dx | The x coordinate of the point relative to the current point |
dy | The y coordinate of the point relative to the current point |
◆ CMDFX_PATH_COMMAND_QUAD_ABSOLUTE
#define CMDFX_PATH_COMMAND_QUAD_ABSOLUTE 'Q' |
Draws a quadratic Bezier curve from the current point to the specified coordinates.
- Parameters
-
x1 | The x coordinate of the control point |
y1 | The y coordinate of the control point |
x2 | The x coordinate of the end point |
y2 | The y coordinate of the end point |
◆ CMDFX_PATH_COMMAND_QUAD_RELATIVE
#define CMDFX_PATH_COMMAND_QUAD_RELATIVE 'q' |
Draws a quadratic Bezier curve from the current point to the specified coordinates relative to the current point.
- Parameters
-
dx1 | The x coordinate of the control point relative to the current point |
dy1 | The y coordinate of the control point relative to the current point |
dx2 | The x coordinate of the end point relative to the current point |
dy2 | The y coordinate of the end point relative to the current point |
◆ CMDFX_PATH_COMMAND_RECT_ABSOLUTE
#define CMDFX_PATH_COMMAND_RECT_ABSOLUTE 'R' |
Draws a rectangle with the specified coordinates.
- Parameters
-
x1 | The x coordinate of the top-left corner of the rectangle |
y1 | The y coordinate of the top-left corner of the rectangle |
x2 | The x coordinate of the bottom-right corner of the rectangle |
y2 | The y coordinate of the bottom-right corner of the rectangle |
◆ CMDFX_PATH_COMMAND_RECT_RELATIVE
#define CMDFX_PATH_COMMAND_RECT_RELATIVE 'r' |
Draws a rectangle with the specified coordinates relative to the current point.
- Parameters
-
dx1 | The x coordinate of the top-left corner of the rectangle relative to the current point |
dy1 | The y coordinate of the top-left corner of the rectangle relative to the current point |
dx2 | The x coordinate of the bottom-right corner of the rectangle relative to the current point |
dy2 | The y coordinate of the bottom-right corner of the rectangle relative to the current point |
◆ CMDFX_PATH_COMMAND_VLINETO_ABSOLUTE
#define CMDFX_PATH_COMMAND_VLINETO_ABSOLUTE 'V' |
Draws a vertical line from the current point to the specified y coordinate.
- Parameters
-
y | The y coordinate of the point |
◆ CMDFX_PATH_COMMAND_VLINETO_RELATIVE
#define CMDFX_PATH_COMMAND_VLINETO_RELATIVE 'v' |
Draws a vertical line from the current point to the specified y coordinate relative to the current point.
- Parameters
-
dy | The y coordinate of the point relative to the current point |
◆ Canvas_path()
int Canvas_path |
( |
const char * | path, |
|
|
char | ch ) |
Draws a path on the canvas using the specified path string.
This function interprets the path string as a series of SVG-like commands and draws the corresponding shapes on the canvas. The path string can contain commands for moving to a point, drawing lines, rectangles, ellipses, and curves, as well as closing the path.
The function will make no attempt to validate the path string, so it is the responsibility of the caller to ensure that the path string is well-formed and contains valid commands. The function will return -1 if the path string is NULL or if an error occurs while drawing the path.
- Parameters
-
path | The path string to draw |
ch | The character to draw |
- Returns
- 0 on success, -1 on error