Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Aug 11, 2024
1 parent efad60d commit bd95d73
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 16 deletions.
101 changes: 86 additions & 15 deletions include/plutovg.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,10 @@ PLUTOVG_API void plutovg_path_close(plutovg_path_t* path);
* position used or the point where the path was last moved to.
*
* @param path A pointer to a `plutovg_path_t` object.
* @param x Output parameter for the x-coordinate of the current point.
* @param y Output parameter for the y-coordinate of the current point.
* @param x The x-coordinate of the current point.
* @param y The y-coordinate of the current point.
*/
PLUTOVG_API void plutovg_path_get_current_point(plutovg_path_t* path, float* x, float* y);
PLUTOVG_API void plutovg_path_get_current_point(const plutovg_path_t* path, float* x, float* y);

/**
* @brief Reserves space for path elements.
Expand Down Expand Up @@ -1243,7 +1243,7 @@ PLUTOVG_API plutovg_surface_t* plutovg_canvas_get_surface(const plutovg_canvas_t
/**
* @brief Saves the current state of the canvas.
*
* @param canvas A pointer to the `plutovg_canvas_t` object.
* @param canvas A pointer to a `plutovg_canvas_t` object.
*/
PLUTOVG_API void plutovg_canvas_save(plutovg_canvas_t* canvas);

Expand Down Expand Up @@ -1784,8 +1784,8 @@ PLUTOVG_API void plutovg_canvas_close_path(plutovg_canvas_t* canvas);
* added or moved to in the current path.
*
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param x Output parameter for the x-coordinate of the current point.
* @param y Output parameter for the y-coordinate of the current point.
* @param x The x-coordinate of the current point.
* @param y The y-coordinate of the current point.
*/
PLUTOVG_API void plutovg_canvas_get_current_point(const plutovg_canvas_t* canvas, float* x, float* y);

Expand All @@ -1795,31 +1795,31 @@ PLUTOVG_API void plutovg_canvas_get_current_point(const plutovg_canvas_t* canvas
* Retrieves the path object representing the sequence of path commands added to the canvas.
*
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @return A pointer to the `plutovg_path_t` object representing the current path.
* @return The current path.
*/
PLUTOVG_API plutovg_path_t* plutovg_canvas_get_path(const plutovg_canvas_t* canvas);

/**
* @brief Gets the bounding box of the filled region.
*
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param extents A pointer to a `plutovg_rect_t` to store the bounding box of the filled region.
* @param extents The bounding box of the filled region.
*/
PLUTOVG_API void plutovg_canvas_fill_extents(const plutovg_canvas_t* canvas, plutovg_rect_t* extents);

/**
* @brief Gets the bounding box of the stroked region.
*
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param extents A pointer to a `plutovg_rect_t` to store the bounding box of the stroked region.
* @param extents The bounding box of the stroked region.
*/
PLUTOVG_API void plutovg_canvas_stroke_extents(const plutovg_canvas_t* canvas, plutovg_rect_t* extents);

/**
* @brief Gets the bounding box of the clipped region.
*
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param extents A pointer to a `plutovg_rect_t` to store the bounding box of the clipped region.
* @param extents The bounding box of the clipped region.
*/
PLUTOVG_API void plutovg_canvas_clip_extents(const plutovg_canvas_t* canvas, plutovg_rect_t* extents);

Expand Down Expand Up @@ -1902,7 +1902,7 @@ PLUTOVG_API void plutovg_canvas_fill_rect(plutovg_canvas_t* canvas, float x, flo
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param path A pointer to a `plutovg_path_t` object.
* @param path The `plutovg_path_t` object.
*/
PLUTOVG_API void plutovg_canvas_fill_path(plutovg_canvas_t* canvas, const plutovg_path_t* path);

Expand All @@ -1923,7 +1923,7 @@ PLUTOVG_API void plutovg_canvas_stroke_rect(plutovg_canvas_t* canvas, float x, f
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param path A pointer to a `plutovg_path_t` object.
* @param path The `plutovg_path_t` object.
*/
PLUTOVG_API void plutovg_canvas_stroke_path(plutovg_canvas_t* canvas, const plutovg_path_t* path);

Expand All @@ -1944,7 +1944,7 @@ PLUTOVG_API void plutovg_canvas_clip_rect(plutovg_canvas_t* canvas, float x, flo
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param path A pointer to a `plutovg_path_t` object.
* @param path The `plutovg_path_t` object.
*/
PLUTOVG_API void plutovg_canvas_clip_path(plutovg_canvas_t* canvas, const plutovg_path_t* path);

Expand All @@ -1963,21 +1963,92 @@ PLUTOVG_API float plutovg_canvas_add_glyph(plutovg_canvas_t* canvas, plutovg_cod
* @brief Adds text to the current path at the specified origin.
*
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param text A pointer to the text data.
* @param length The length of the text data.
* @param text The text data.
* @param length The length of the text data, or -1 if null-terminated.
* @param encoding The encoding of the text data.
* @param x The x-coordinate of the origin.
* @param y The y-coordinate of the origin.
* @return The total advance width of the text.
*/
PLUTOVG_API float plutovg_canvas_add_text(plutovg_canvas_t* canvas, const void* text, int length, plutovg_text_encoding_t encoding, float x, float y);

/**
* @brief Fills a text at the specified origin.
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param text The text data.
* @param length The length of the text data, or -1 if null-terminated.
* @param encoding The encoding of the text data.
* @param x The x-coordinate of the origin.
* @param y The y-coordinate of the origin.
* @return The total advance width of the text.
*/
PLUTOVG_API float plutovg_canvas_fill_text(plutovg_canvas_t* canvas, const void* text, int length, plutovg_text_encoding_t encoding, float x, float y);

/**
* @brief Strokes a text at the specified origin.
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param text The text data.
* @param length The length of the text data, or -1 if null-terminated.
* @param encoding The encoding of the text data.
* @param x The x-coordinate of the origin.
* @param y The y-coordinate of the origin.
* @return The total advance width of the text.
*/
PLUTOVG_API float plutovg_canvas_stroke_text(plutovg_canvas_t* canvas, const void* text, int length, plutovg_text_encoding_t encoding, float x, float y);

/**
* @brief Intersects the current clipping region with text at the specified origin.
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param text The text data.
* @param length The length of the text data, or -1 if null-terminated.
* @param encoding The encoding of the text data.
* @param x The x-coordinate of the origin.
* @param y The y-coordinate of the origin.
* @return The total advance width of the text.
*/
PLUTOVG_API float plutovg_canvas_clip_text(plutovg_canvas_t* canvas, const void* text, int length, plutovg_text_encoding_t encoding, float x, float y);

/**
* @brief Retrieves font metrics for the current font.
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param ascent The ascent of the font.
* @param descent The descent of the font.
* @param line_gap The line gap of the font.
* @param extents The bounding box of the font.
*/
PLUTOVG_API void plutovg_canvas_font_metrics(plutovg_canvas_t* canvas, float* ascent, float* descent, float* line_gap, plutovg_rect_t* extents);

/**
* @brief Retrieves metrics for a specific glyph.
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param codepoint The glyph codepoint.
* @param advance_width The advance width of the glyph.
* @param left_side_bearing The left side bearing of the glyph.
* @param extents The bounding box of the glyph.
*/
PLUTOVG_API void plutovg_canvas_glyph_metrics(plutovg_canvas_t* canvas, plutovg_codepoint_t codepoint, float* advance_width, float* left_side_bearing, plutovg_rect_t* extents);

/**
* @brief Retrieves the extents of a text.
*
* @note The current path will be cleared by this operation.
* @param canvas A pointer to a `plutovg_canvas_t` object.
* @param text The text data.
* @param length The length of the text data, or -1 if null-terminated.
* @param encoding The encoding of the text data.
* @param extents The bounding box of the text.
* @return The total advance width of the text.
*/
PLUTOVG_API float plutovg_canvas_text_extents(plutovg_canvas_t* canvas, const void* text, int length, plutovg_text_encoding_t encoding, plutovg_rect_t* extents);

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion source/plutovg-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void plutovg_path_close(plutovg_path_t* path)
elements[0].point.y = path->start_point.y;
}

void plutovg_path_get_current_point(plutovg_path_t* path, float* x, float* y)
void plutovg_path_get_current_point(const plutovg_path_t* path, float* x, float* y)
{
float xx = 0.f;
float yy = 0.f;
Expand Down

0 comments on commit bd95d73

Please sign in to comment.