|
@@ -1,17 +1,3 @@
|
|
-/*!
|
|
|
|
- * @file thorvg.h
|
|
|
|
- *
|
|
|
|
- * The main APIs enabling the TVG initialization, preparation of the canvas and provisioning of its content:
|
|
|
|
- * - drawing shapes: line, arc, curve, path, polygon...
|
|
|
|
- * - drawing pictures: tvg, svg, png, jpg, bitmap...
|
|
|
|
- * - drawing fillings: solid, linear and radial gradient...
|
|
|
|
- * - drawing stroking: continuous stroking with arbitrary width, join, cap, dash styles.
|
|
|
|
- * - drawing composition: blending, masking, path clipping...
|
|
|
|
- * - drawing scene graph & affine transformation (translation, rotation, scale, ...)
|
|
|
|
- * and finally drawing the canvas and TVG termination.
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
-
|
|
|
|
#ifndef _THORVG_H_
|
|
#ifndef _THORVG_H_
|
|
#define _THORVG_H_
|
|
#define _THORVG_H_
|
|
|
|
|
|
@@ -172,10 +158,10 @@ enum class CompositeMethod
|
|
InvAlphaMask, ///< Alpha Masking using the complement to the compositing target's pixels as an alpha value.
|
|
InvAlphaMask, ///< Alpha Masking using the complement to the compositing target's pixels as an alpha value.
|
|
LumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the compositing target's pixels. @since 0.9
|
|
LumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the compositing target's pixels. @since 0.9
|
|
InvLumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the complement to the compositing target's pixels.
|
|
InvLumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the complement to the compositing target's pixels.
|
|
- AddMask, ///< Combines the target and source objects pixels using target alpha. (T * TA) + (S * (255 - TA)) @BETA_API
|
|
|
|
- SubtractMask, ///< Subtracts the source color from the target color while considering their respective target alpha. (T * TA) - (S * (255 - TA)) @BETA_API
|
|
|
|
- IntersectMask, ///< Computes the result by taking the minimum value between the target alpha and the source alpha and multiplies it with the target color. (T * min(TA, SA)) @BETA_API
|
|
|
|
- DifferenceMask ///< Calculates the absolute difference between the target color and the source color multiplied by the complement of the target alpha. abs(T - S * (255 - TA)) @BETA_API
|
|
|
|
|
|
+ AddMask, ///< Combines the target and source objects pixels using target alpha. (T * TA) + (S * (255 - TA)) (Experimental API)
|
|
|
|
+ SubtractMask, ///< Subtracts the source color from the target color while considering their respective target alpha. (T * TA) - (S * (255 - TA)) (Experimental API)
|
|
|
|
+ IntersectMask, ///< Computes the result by taking the minimum value between the target alpha and the source alpha and multiplies it with the target color. (T * min(TA, SA)) (Experimental API)
|
|
|
|
+ DifferenceMask ///< Calculates the absolute difference between the target color and the source color multiplied by the complement of the target alpha. abs(T - S * (255 - TA)) (Experimental API)
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -186,7 +172,7 @@ enum class CompositeMethod
|
|
*
|
|
*
|
|
* @see Paint::blend()
|
|
* @see Paint::blend()
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
enum class BlendMethod : uint8_t
|
|
enum class BlendMethod : uint8_t
|
|
{
|
|
{
|
|
@@ -213,7 +199,8 @@ enum class BlendMethod : uint8_t
|
|
enum class CanvasEngine
|
|
enum class CanvasEngine
|
|
{
|
|
{
|
|
Sw = (1 << 1), ///< CPU rasterizer.
|
|
Sw = (1 << 1), ///< CPU rasterizer.
|
|
- Gl = (1 << 2) ///< OpenGL rasterizer.
|
|
|
|
|
|
+ Gl = (1 << 2), ///< OpenGL rasterizer.
|
|
|
|
+ Wg = (1 << 3), ///< WebGPU rasterizer. (Experimental API)
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -247,7 +234,7 @@ struct Matrix
|
|
* @param pt The vertex coordinate
|
|
* @param pt The vertex coordinate
|
|
* @param uv The normalized texture coordinate in the range (0.0..1.0, 0.0..1.0)
|
|
* @param uv The normalized texture coordinate in the range (0.0..1.0, 0.0..1.0)
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
struct Vertex
|
|
struct Vertex
|
|
{
|
|
{
|
|
@@ -261,7 +248,7 @@ struct Vertex
|
|
*
|
|
*
|
|
* @param vertex The three vertices that make up the polygon
|
|
* @param vertex The three vertices that make up the polygon
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
struct Polygon
|
|
struct Polygon
|
|
{
|
|
{
|
|
@@ -291,7 +278,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] degree The value of the angle in degrees.
|
|
* @param[in] degree The value of the angle in degrees.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result rotate(float degree) noexcept;
|
|
Result rotate(float degree) noexcept;
|
|
|
|
|
|
@@ -300,7 +287,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] factor The value of the scaling factor. The default value is 1.
|
|
* @param[in] factor The value of the scaling factor. The default value is 1.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result scale(float factor) noexcept;
|
|
Result scale(float factor) noexcept;
|
|
|
|
|
|
@@ -313,7 +300,7 @@ public:
|
|
* @param[in] x The value of the horizontal shift.
|
|
* @param[in] x The value of the horizontal shift.
|
|
* @param[in] y The value of the vertical shift.
|
|
* @param[in] y The value of the vertical shift.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result translate(float x, float y) noexcept;
|
|
Result translate(float x, float y) noexcept;
|
|
|
|
|
|
@@ -324,7 +311,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] m The 3x3 augmented matrix.
|
|
* @param[in] m The 3x3 augmented matrix.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result transform(const Matrix& m) noexcept;
|
|
Result transform(const Matrix& m) noexcept;
|
|
|
|
|
|
@@ -345,7 +332,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] o The opacity value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
|
|
* @param[in] o The opacity value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note Setting the opacity with this API may require multiple render pass for composition. It is recommended to avoid changing the opacity if possible.
|
|
* @note Setting the opacity with this API may require multiple render pass for composition. It is recommended to avoid changing the opacity if possible.
|
|
* @note ClipPath won't use the opacity value. (see: enum class CompositeMethod::ClipPath)
|
|
* @note ClipPath won't use the opacity value. (see: enum class CompositeMethod::ClipPath)
|
|
@@ -358,7 +345,7 @@ public:
|
|
* @param[in] target The paint of the target object.
|
|
* @param[in] target The paint of the target object.
|
|
* @param[in] method The method used to composite the source object with the target.
|
|
* @param[in] method The method used to composite the source object with the target.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InvalidArguments otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InvalidArguments otherwise.
|
|
*/
|
|
*/
|
|
Result composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept;
|
|
Result composite(std::unique_ptr<Paint> target, CompositeMethod method) noexcept;
|
|
|
|
|
|
@@ -371,9 +358,9 @@ public:
|
|
*
|
|
*
|
|
* @param[in] method The blending method to be set.
|
|
* @param[in] method The blending method to be set.
|
|
*
|
|
*
|
|
- * @return Result::Success when the blending method is successfully set.
|
|
|
|
|
|
+ * @retval Result::Success when the blending method is successfully set.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
Result blend(BlendMethod method) const noexcept;
|
|
Result blend(BlendMethod method) const noexcept;
|
|
|
|
|
|
@@ -404,7 +391,7 @@ public:
|
|
* @param[out] h The height of the object.
|
|
* @param[out] h The height of the object.
|
|
* @param[in] transformed If @c true, the paint's transformations are taken into account, otherwise they aren't.
|
|
* @param[in] transformed If @c true, the paint's transformations are taken into account, otherwise they aren't.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
*
|
|
*
|
|
* @note The bounding box doesn't indicate the actual drawing region. It's the smallest rectangle that encloses the object.
|
|
* @note The bounding box doesn't indicate the actual drawing region. It's the smallest rectangle that encloses the object.
|
|
*/
|
|
*/
|
|
@@ -442,7 +429,7 @@ public:
|
|
*
|
|
*
|
|
* @return The blending method
|
|
* @return The blending method
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
BlendMethod blend() const noexcept;
|
|
BlendMethod blend() const noexcept;
|
|
|
|
|
|
@@ -493,7 +480,7 @@ public:
|
|
* @param[in] colorStops An array of ColorStop data structure.
|
|
* @param[in] colorStops An array of ColorStop data structure.
|
|
* @param[in] cnt The count of the @p colorStops array equal to the colors number used in the gradient.
|
|
* @param[in] cnt The count of the @p colorStops array equal to the colors number used in the gradient.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
|
|
Result colorStops(const ColorStop* colorStops, uint32_t cnt) noexcept;
|
|
|
|
|
|
@@ -502,7 +489,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] s The FillSpread value.
|
|
* @param[in] s The FillSpread value.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result spread(FillSpread s) noexcept;
|
|
Result spread(FillSpread s) noexcept;
|
|
|
|
|
|
@@ -513,7 +500,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] m The 3x3 augmented matrix.
|
|
* @param[in] m The 3x3 augmented matrix.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result transform(const Matrix& m) noexcept;
|
|
Result transform(const Matrix& m) noexcept;
|
|
|
|
|
|
@@ -538,7 +525,7 @@ public:
|
|
*
|
|
*
|
|
* In case no transformation was applied, the identity matrix is returned.
|
|
* In case no transformation was applied, the identity matrix is returned.
|
|
*
|
|
*
|
|
- * @retval The augmented transformation matrix.
|
|
|
|
|
|
+ * @return The augmented transformation matrix.
|
|
*/
|
|
*/
|
|
Matrix transform() const noexcept;
|
|
Matrix transform() const noexcept;
|
|
|
|
|
|
@@ -600,7 +587,7 @@ public:
|
|
* @warning Please avoid accessing the paints during Canvas update/draw. You can access them after calling sync().
|
|
* @warning Please avoid accessing the paints during Canvas update/draw. You can access them after calling sync().
|
|
* @see Canvas::sync()
|
|
* @see Canvas::sync()
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
std::list<Paint*>& paints() noexcept;
|
|
std::list<Paint*>& paints() noexcept;
|
|
|
|
|
|
@@ -631,7 +618,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] free If @c true, the memory occupied by paints is deallocated, otherwise it is not.
|
|
* @param[in] free If @c true, the memory occupied by paints is deallocated, otherwise it is not.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
*
|
|
*
|
|
* @see Canvas::push()
|
|
* @see Canvas::push()
|
|
* @see Canvas::paints()
|
|
* @see Canvas::paints()
|
|
@@ -646,7 +633,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] paint A pointer to the Paint object or @c nullptr.
|
|
* @param[in] paint A pointer to the Paint object or @c nullptr.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
*
|
|
*
|
|
* @note The Update behavior can be asynchronous if the assigned thread number is greater than zero.
|
|
* @note The Update behavior can be asynchronous if the assigned thread number is greater than zero.
|
|
*/
|
|
*/
|
|
@@ -655,7 +642,7 @@ public:
|
|
/**
|
|
/**
|
|
* @brief Requests the canvas to draw the Paint objects.
|
|
* @brief Requests the canvas to draw the Paint objects.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
*
|
|
*
|
|
* @note Drawing can be asynchronous if the assigned thread number is greater than zero. To guarantee the drawing is done, call sync() afterwards.
|
|
* @note Drawing can be asynchronous if the assigned thread number is greater than zero. To guarantee the drawing is done, call sync() afterwards.
|
|
* @see Canvas::sync()
|
|
* @see Canvas::sync()
|
|
@@ -668,7 +655,7 @@ public:
|
|
* The Canvas rendering can be performed asynchronously. To make sure that rendering is finished,
|
|
* The Canvas rendering can be performed asynchronously. To make sure that rendering is finished,
|
|
* the sync() must be called after the draw() regardless of threading.
|
|
* the sync() must be called after the draw() regardless of threading.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
* @see Canvas::draw()
|
|
* @see Canvas::draw()
|
|
*/
|
|
*/
|
|
virtual Result sync() noexcept;
|
|
virtual Result sync() noexcept;
|
|
@@ -702,7 +689,7 @@ public:
|
|
* @param[in] x2 The horizontal coordinate of the second point used to determine the gradient bounds.
|
|
* @param[in] x2 The horizontal coordinate of the second point used to determine the gradient bounds.
|
|
* @param[in] y2 The vertical coordinate of the second point used to determine the gradient bounds.
|
|
* @param[in] y2 The vertical coordinate of the second point used to determine the gradient bounds.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note In case the first and the second points are equal, an object filled with such a gradient fill is not rendered.
|
|
* @note In case the first and the second points are equal, an object filled with such a gradient fill is not rendered.
|
|
*/
|
|
*/
|
|
@@ -720,7 +707,7 @@ public:
|
|
* @param[out] x2 The horizontal coordinate of the second point used to determine the gradient bounds.
|
|
* @param[out] x2 The horizontal coordinate of the second point used to determine the gradient bounds.
|
|
* @param[out] y2 The vertical coordinate of the second point used to determine the gradient bounds.
|
|
* @param[out] y2 The vertical coordinate of the second point used to determine the gradient bounds.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
|
|
Result linear(float* x1, float* y1, float* x2, float* y2) const noexcept;
|
|
|
|
|
|
@@ -764,7 +751,7 @@ public:
|
|
* @param[in] cy The vertical coordinate of the center of the bounding circle.
|
|
* @param[in] cy The vertical coordinate of the center of the bounding circle.
|
|
* @param[in] radius The radius of the bounding circle.
|
|
* @param[in] radius The radius of the bounding circle.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InvalidArguments in case the @p radius value is zero or less.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InvalidArguments in case the @p radius value is zero or less.
|
|
*/
|
|
*/
|
|
Result radial(float cx, float cy, float radius) noexcept;
|
|
Result radial(float cx, float cy, float radius) noexcept;
|
|
|
|
|
|
@@ -777,7 +764,7 @@ public:
|
|
* @param[out] cy The vertical coordinate of the center of the bounding circle.
|
|
* @param[out] cy The vertical coordinate of the center of the bounding circle.
|
|
* @param[out] radius The radius of the bounding circle.
|
|
* @param[out] radius The radius of the bounding circle.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result radial(float* cx, float* cy, float* radius) const noexcept;
|
|
Result radial(float* cx, float* cy, float* radius) const noexcept;
|
|
|
|
|
|
@@ -823,7 +810,7 @@ public:
|
|
*
|
|
*
|
|
* The transformation matrix, the color, the fill and the stroke properties are retained.
|
|
* The transformation matrix, the color, the fill and the stroke properties are retained.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note The memory, where the path data is stored, is not deallocated at this stage for caching effect.
|
|
* @note The memory, where the path data is stored, is not deallocated at this stage for caching effect.
|
|
*/
|
|
*/
|
|
@@ -837,7 +824,7 @@ public:
|
|
* @param[in] x The horizontal coordinate of the initial point of the sub-path.
|
|
* @param[in] x The horizontal coordinate of the initial point of the sub-path.
|
|
* @param[in] y The vertical coordinate of the initial point of the sub-path.
|
|
* @param[in] y The vertical coordinate of the initial point of the sub-path.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result moveTo(float x, float y) noexcept;
|
|
Result moveTo(float x, float y) noexcept;
|
|
|
|
|
|
@@ -849,7 +836,7 @@ public:
|
|
* @param[in] x The horizontal coordinate of the end-point of the line.
|
|
* @param[in] x The horizontal coordinate of the end-point of the line.
|
|
* @param[in] y The vertical coordinate of the end-point of the line.
|
|
* @param[in] y The vertical coordinate of the end-point of the line.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note In case this is the first command in the path, it corresponds to the moveTo() call.
|
|
* @note In case this is the first command in the path, it corresponds to the moveTo() call.
|
|
*/
|
|
*/
|
|
@@ -868,7 +855,7 @@ public:
|
|
* @param[in] x The horizontal coordinate of the end-point of the curve.
|
|
* @param[in] x The horizontal coordinate of the end-point of the curve.
|
|
* @param[in] y The vertical coordinate of the end-point of the curve.
|
|
* @param[in] y The vertical coordinate of the end-point of the curve.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note In case this is the first command in the path, no data from the path are rendered.
|
|
* @note In case this is the first command in the path, no data from the path are rendered.
|
|
*/
|
|
*/
|
|
@@ -879,7 +866,7 @@ public:
|
|
*
|
|
*
|
|
* The value of the current point is set to the initial point of the closed sub-path.
|
|
* The value of the current point is set to the initial point of the closed sub-path.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note In case the sub-path does not contain any points, this function has no effect.
|
|
* @note In case the sub-path does not contain any points, this function has no effect.
|
|
*/
|
|
*/
|
|
@@ -905,7 +892,7 @@ public:
|
|
* @param[in] rx The x-axis radius of the ellipse defining the rounded corners of the rectangle.
|
|
* @param[in] rx The x-axis radius of the ellipse defining the rounded corners of the rectangle.
|
|
* @param[in] ry The y-axis radius of the ellipse defining the rounded corners of the rectangle.
|
|
* @param[in] ry The y-axis radius of the ellipse defining the rounded corners of the rectangle.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note For @p rx and @p ry greater than or equal to the half of @p w and the half of @p h, respectively, the shape become an ellipse.
|
|
* @note For @p rx and @p ry greater than or equal to the half of @p w and the half of @p h, respectively, the shape become an ellipse.
|
|
*/
|
|
*/
|
|
@@ -925,7 +912,7 @@ public:
|
|
* @param[in] rx The x-axis radius of the ellipse.
|
|
* @param[in] rx The x-axis radius of the ellipse.
|
|
* @param[in] ry The y-axis radius of the ellipse.
|
|
* @param[in] ry The y-axis radius of the ellipse.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result appendCircle(float cx, float cy, float rx, float ry) noexcept;
|
|
Result appendCircle(float cx, float cy, float rx, float ry) noexcept;
|
|
|
|
|
|
@@ -942,7 +929,7 @@ public:
|
|
* @param[in] sweep The central angle of the arc given in degrees, measured counter-clockwise from @p startAngle.
|
|
* @param[in] sweep The central angle of the arc given in degrees, measured counter-clockwise from @p startAngle.
|
|
* @param[in] pie Specifies whether to draw radii from the arc's center to both of its end-point - drawn if @c true.
|
|
* @param[in] pie Specifies whether to draw radii from the arc's center to both of its end-point - drawn if @c true.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note Setting @p sweep value greater than 360 degrees, is equivalent to calling appendCircle(cx, cy, radius, radius).
|
|
* @note Setting @p sweep value greater than 360 degrees, is equivalent to calling appendCircle(cx, cy, radius, radius).
|
|
*/
|
|
*/
|
|
@@ -960,7 +947,7 @@ public:
|
|
* @param[in] pts The array of the two-dimensional points.
|
|
* @param[in] pts The array of the two-dimensional points.
|
|
* @param[in] ptsCnt The number of the points in the @p pts array.
|
|
* @param[in] ptsCnt The number of the points in the @p pts array.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InvalidArguments otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InvalidArguments otherwise.
|
|
*
|
|
*
|
|
* @note The interface is designed for optimal path setting if the caller has a completed path commands already.
|
|
* @note The interface is designed for optimal path setting if the caller has a completed path commands already.
|
|
*/
|
|
*/
|
|
@@ -971,7 +958,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] width The width of the stroke. The default value is 0.
|
|
* @param[in] width The width of the stroke. The default value is 0.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result stroke(float width) noexcept;
|
|
Result stroke(float width) noexcept;
|
|
|
|
|
|
@@ -983,7 +970,7 @@ public:
|
|
* @param[in] b The blue color channel value in the range [0 ~ 255]. The default value is 0.
|
|
* @param[in] b The blue color channel value in the range [0 ~ 255]. The default value is 0.
|
|
* @param[in] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. The default value is 0.
|
|
* @param[in] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. The default value is 0.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
|
|
Result stroke(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept;
|
|
|
|
|
|
@@ -1018,7 +1005,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] cap The cap style value. The default value is @c StrokeCap::Square.
|
|
* @param[in] cap The cap style value. The default value is @c StrokeCap::Square.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result stroke(StrokeCap cap) noexcept;
|
|
Result stroke(StrokeCap cap) noexcept;
|
|
|
|
|
|
@@ -1029,7 +1016,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] join The join style value. The default value is @c StrokeJoin::Bevel.
|
|
* @param[in] join The join style value. The default value is @c StrokeJoin::Bevel.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*/
|
|
*/
|
|
Result stroke(StrokeJoin join) noexcept;
|
|
Result stroke(StrokeJoin join) noexcept;
|
|
|
|
|
|
@@ -1039,7 +1026,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] miterlimit The miterlimit imposes a limit on the extent of the stroke join, when the @c StrokeJoin::Miter join style is set. The default value is 4.
|
|
* @param[in] miterlimit The miterlimit imposes a limit on the extent of the stroke join, when the @c StrokeJoin::Miter join style is set. The default value is 4.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::NonSupport unsupported value, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::NonSupport unsupported value, Result::FailedAllocation otherwise.
|
|
*
|
|
*
|
|
* @since 0.11
|
|
* @since 0.11
|
|
*/
|
|
*/
|
|
@@ -1055,7 +1042,7 @@ public:
|
|
* @param[in] b The blue color channel value in the range [0 ~ 255]. The default value is 0.
|
|
* @param[in] b The blue color channel value in the range [0 ~ 255]. The default value is 0.
|
|
* @param[in] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. The default value is 0.
|
|
* @param[in] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque. The default value is 0.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*
|
|
*
|
|
* @note Either a solid color or a gradient fill is applied, depending on what was set as last.
|
|
* @note Either a solid color or a gradient fill is applied, depending on what was set as last.
|
|
* @note ClipPath won't use the fill values. (see: enum class CompositeMethod::ClipPath)
|
|
* @note ClipPath won't use the fill values. (see: enum class CompositeMethod::ClipPath)
|
|
@@ -1069,7 +1056,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] f The unique pointer to the gradient fill.
|
|
* @param[in] f The unique pointer to the gradient fill.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::MemoryCorruption otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::MemoryCorruption otherwise.
|
|
*
|
|
*
|
|
* @note Either a solid color or a gradient fill is applied, depending on what was set as last.
|
|
* @note Either a solid color or a gradient fill is applied, depending on what was set as last.
|
|
*/
|
|
*/
|
|
@@ -1080,7 +1067,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] r The fill rule value. The default value is @c FillRule::Winding.
|
|
* @param[in] r The fill rule value. The default value is @c FillRule::Winding.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result fill(FillRule r) noexcept;
|
|
Result fill(FillRule r) noexcept;
|
|
|
|
|
|
@@ -1090,7 +1077,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] strokeFirst If @c true the stroke is rendered before the fill, otherwise the stroke is rendered as the second one (the default option).
|
|
* @param[in] strokeFirst If @c true the stroke is rendered before the fill, otherwise the stroke is rendered as the second one (the default option).
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::FailedAllocation otherwise.
|
|
*
|
|
*
|
|
* @since 0.10
|
|
* @since 0.10
|
|
*/
|
|
*/
|
|
@@ -1156,7 +1143,7 @@ public:
|
|
* @param[out] b The blue color channel value in the range [0 ~ 255].
|
|
* @param[out] b The blue color channel value in the range [0 ~ 255].
|
|
* @param[out] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
|
|
* @param[out] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
*/
|
|
*/
|
|
Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
|
|
Result strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) const noexcept;
|
|
|
|
|
|
@@ -1295,7 +1282,7 @@ public:
|
|
* @param[in] w A new width of the image in pixels.
|
|
* @param[in] w A new width of the image in pixels.
|
|
* @param[in] h A new height of the image in pixels.
|
|
* @param[in] h A new height of the image in pixels.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::InsufficientCondition otherwise.
|
|
*/
|
|
*/
|
|
Result size(float w, float h) noexcept;
|
|
Result size(float w, float h) noexcept;
|
|
|
|
|
|
@@ -1305,13 +1292,20 @@ public:
|
|
* @param[out] w The width of the image in pixels.
|
|
* @param[out] w The width of the image in pixels.
|
|
* @param[out] h The height of the image in pixels.
|
|
* @param[out] h The height of the image in pixels.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed.
|
|
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
*/
|
|
*/
|
|
Result size(float* w, float* h) const noexcept;
|
|
Result size(float* w, float* h) const noexcept;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @brief Loads a raw data from a memory block with a given size.
|
|
* @brief Loads a raw data from a memory block with a given size.
|
|
*
|
|
*
|
|
|
|
+ * @param[in] paint A Tvg_Paint pointer to the picture object.
|
|
|
|
+ * @param[in] data A pointer to a memory location where the content of the picture raw data is stored.
|
|
|
|
+ * @param[in] w The width of the image @p data in pixels.
|
|
|
|
+ * @param[in] h The height of the image @p data in pixels.
|
|
|
|
+ * @param[in] premultiplied If @c true, the given image data is alpha-premultiplied.
|
|
|
|
+ * @param[in] copy If @c true the data are copied into the engine local buffer, otherwise they are not.
|
|
|
|
+ *
|
|
* @retval Result::Success When succeed, Result::InsufficientCondition otherwise.
|
|
* @retval Result::Success When succeed, Result::InsufficientCondition otherwise.
|
|
* @retval Result::FailedAllocation An internal error possibly with memory allocation.
|
|
* @retval Result::FailedAllocation An internal error possibly with memory allocation.
|
|
*
|
|
*
|
|
@@ -1339,7 +1333,7 @@ public:
|
|
* @note The Polygons are copied internally, so modifying them after calling Mesh::mesh has no affect.
|
|
* @note The Polygons are copied internally, so modifying them after calling Mesh::mesh has no affect.
|
|
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
Result mesh(const Polygon* triangles, uint32_t triangleCnt) noexcept;
|
|
Result mesh(const Polygon* triangles, uint32_t triangleCnt) noexcept;
|
|
|
|
|
|
@@ -1348,12 +1342,12 @@ public:
|
|
*
|
|
*
|
|
* @param[out] triangles Optional. A pointer to the array of Polygons used by this mesh.
|
|
* @param[out] triangles Optional. A pointer to the array of Polygons used by this mesh.
|
|
*
|
|
*
|
|
- * @return uint32_t The number of polygons in the array.
|
|
|
|
|
|
+ * @return The number of polygons in the array.
|
|
*
|
|
*
|
|
* @note Modifying the triangles returned by this method will modify them directly within the mesh.
|
|
* @note Modifying the triangles returned by this method will modify them directly within the mesh.
|
|
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
uint32_t mesh(const Polygon** triangles) const noexcept;
|
|
uint32_t mesh(const Polygon** triangles) const noexcept;
|
|
|
|
|
|
@@ -1402,7 +1396,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] paint A Paint object to be drawn.
|
|
* @param[in] paint A Paint object to be drawn.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed, Result::MemoryCorruption otherwise.
|
|
|
|
|
|
+ * @retval Result::Success when succeed, Result::MemoryCorruption otherwise.
|
|
*
|
|
*
|
|
* @note The rendering order of the paints is the same as the order as they were pushed. Consider sorting the paints before pushing them if you intend to use layering.
|
|
* @note The rendering order of the paints is the same as the order as they were pushed. Consider sorting the paints before pushing them if you intend to use layering.
|
|
* @see Scene::paints()
|
|
* @see Scene::paints()
|
|
@@ -1432,7 +1426,7 @@ public:
|
|
* @see Scene::push()
|
|
* @see Scene::push()
|
|
* @see Scene::clear()
|
|
* @see Scene::clear()
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
std::list<Paint*>& paints() noexcept;
|
|
std::list<Paint*>& paints() noexcept;
|
|
|
|
|
|
@@ -1442,7 +1436,7 @@ public:
|
|
*
|
|
*
|
|
* @param[in] free If @c true, the memory occupied by paints is deallocated, otherwise it is not.
|
|
* @param[in] free If @c true, the memory occupied by paints is deallocated, otherwise it is not.
|
|
*
|
|
*
|
|
- * @return Result::Success when succeed
|
|
|
|
|
|
+ * @retval Result::Success when succeed
|
|
*
|
|
*
|
|
* @warning If you don't free the paints they become dangled. They are supposed to be reused, otherwise you are responsible for their lives. Thus please use the @p free argument only when you know how it works, otherwise it's not recommended.
|
|
* @warning If you don't free the paints they become dangled. They are supposed to be reused, otherwise you are responsible for their lives. Thus please use the @p free argument only when you know how it works, otherwise it's not recommended.
|
|
*
|
|
*
|
|
@@ -1470,6 +1464,138 @@ public:
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * @class Text
|
|
|
|
+ *
|
|
|
|
+ * @brief A class to represent text objects in a graphical context, allowing for rendering and manipulation of unicode text.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+class TVG_API Text final : public Paint
|
|
|
|
+{
|
|
|
|
+public:
|
|
|
|
+ ~Text();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Sets the font properties for the text.
|
|
|
|
+ *
|
|
|
|
+ * This function allows you to define the font characteristics used for text rendering.
|
|
|
|
+ * It sets the font name, size and optionally the style.
|
|
|
|
+ *
|
|
|
|
+ * @param[in] name The name of the font. This should correspond to a font available in the canvas.
|
|
|
|
+ * @param[in] size The size of the font in points. This determines how large the text will appear.
|
|
|
|
+ * @param[in] style The style of the font. It can be used to set the font to 'italic'.
|
|
|
|
+ * If not specified, the default style is used. Only 'italic' style is supported currently.
|
|
|
|
+ *
|
|
|
|
+ * @retval Result::Success when the font properties are set successfully.
|
|
|
|
+ * @retval Result::InsufficientCondition when the specified @p name cannot be found.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+ Result font(const char* name, float size, const char* style = nullptr) noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Assigns the given unicode text to be rendered.
|
|
|
|
+ *
|
|
|
|
+ * This function sets the unicode string that will be displayed by the rendering system.
|
|
|
|
+ * The text is set according to the specified UTF encoding method, which defaults to UTF-8.
|
|
|
|
+ *
|
|
|
|
+ * @param[in] text The multi-byte text encoded with utf8 string to be rendered.
|
|
|
|
+ *
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+ Result text(const char* text) noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Sets the text color.
|
|
|
|
+ *
|
|
|
|
+ * @param[in] r The red color channel value in the range [0 ~ 255]. The default value is 0.
|
|
|
|
+ * @param[in] g The green color channel value in the range [0 ~ 255]. The default value is 0.
|
|
|
|
+ * @param[in] b The blue color channel value in the range [0 ~ 255]. The default value is 0.
|
|
|
|
+ *
|
|
|
|
+ * @retval Result::Success when succeed.
|
|
|
|
+ * @retval Result::InsufficientCondition when the font has not been set up prior to this operation.
|
|
|
|
+ *
|
|
|
|
+ * @see Text::font()
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+ Result fill(uint8_t r, uint8_t g, uint8_t b) noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Sets the gradient fill for all of the figures from the text.
|
|
|
|
+ *
|
|
|
|
+ * The parts of the text defined as inner are filled.
|
|
|
|
+ *
|
|
|
|
+ * @param[in] f The unique pointer to the gradient fill.
|
|
|
|
+ *
|
|
|
|
+ * @retval Result::Success when succeed, Result::MemoryCorruption otherwise.
|
|
|
|
+ * @retval Result::InsufficientCondition when the font has not been set up prior to this operation.
|
|
|
|
+ *
|
|
|
|
+ * @note Either a solid color or a gradient fill is applied, depending on what was set as last.
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ *
|
|
|
|
+ * @see Text::font()
|
|
|
|
+ */
|
|
|
|
+ Result fill(std::unique_ptr<Fill> f) noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Loads a scalable font data(ttf) from a file.
|
|
|
|
+ *
|
|
|
|
+ * @param[in] path The path to the font file.
|
|
|
|
+ *
|
|
|
|
+ * @retval Result::Success When succeed.
|
|
|
|
+ * @retval Result::InvalidArguments In case the @p path is invalid.
|
|
|
|
+ * @retval Result::NonSupport When trying to load a file with an unknown extension.
|
|
|
|
+ * @retval Result::Unknown If an error occurs at a later stage.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ *
|
|
|
|
+ * @see Text::unload(const std::string& path)
|
|
|
|
+ */
|
|
|
|
+ static Result load(const std::string& path) noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Unloads the specified scalable font data (TTF) that was previously loaded.
|
|
|
|
+ *
|
|
|
|
+ * This function is used to release resources associated with a font file that has been loaded into memory.
|
|
|
|
+ *
|
|
|
|
+ * @param[in] path The file path of the loaded font.
|
|
|
|
+ *
|
|
|
|
+ * @retval Result::Success Successfully unloads the font data.
|
|
|
|
+ * @retval Result::InsufficientCondition Fails if the loader is not initialized.
|
|
|
|
+ *
|
|
|
|
+ * @note If the font data is currently in use, it will not be immediately unloaded.
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ *
|
|
|
|
+ * @see Text::load(const std::string& path)
|
|
|
|
+ */
|
|
|
|
+ static Result unload(const std::string& path) noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Creates a new Text object.
|
|
|
|
+ *
|
|
|
|
+ * @return A new Text object.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+ static std::unique_ptr<Text> gen() noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Return the unique id value of this class.
|
|
|
|
+ *
|
|
|
|
+ * This method can be referred for identifying the Text class type.
|
|
|
|
+ *
|
|
|
|
+ * @return The type id of the Text class.
|
|
|
|
+ */
|
|
|
|
+ static uint32_t identifier() noexcept;
|
|
|
|
+
|
|
|
|
+ _TVG_DECLARE_PRIVATE(Text);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @class SwCanvas
|
|
* @class SwCanvas
|
|
*
|
|
*
|
|
@@ -1487,8 +1613,8 @@ public:
|
|
{
|
|
{
|
|
ABGR8888 = 0, ///< The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied. (a << 24 | b << 16 | g << 8 | r)
|
|
ABGR8888 = 0, ///< The channels are joined in the order: alpha, blue, green, red. Colors are alpha-premultiplied. (a << 24 | b << 16 | g << 8 | r)
|
|
ARGB8888, ///< The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied. (a << 24 | r << 16 | g << 8 | b)
|
|
ARGB8888, ///< The channels are joined in the order: alpha, red, green, blue. Colors are alpha-premultiplied. (a << 24 | r << 16 | g << 8 | b)
|
|
- ABGR8888S, ///< @BETA_API The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied.
|
|
|
|
- ARGB8888S, ///< @BETA_API The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied.
|
|
|
|
|
|
+ ABGR8888S, ///< The channels are joined in the order: alpha, blue, green, red. Colors are un-alpha-premultiplied. @since 0.12
|
|
|
|
+ ARGB8888S, ///< The channels are joined in the order: alpha, red, green, blue. Colors are un-alpha-premultiplied. @since 0.12
|
|
};
|
|
};
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1564,7 +1690,7 @@ public:
|
|
*
|
|
*
|
|
* @warning Please do not use it. This class is not fully supported yet.
|
|
* @warning Please do not use it. This class is not fully supported yet.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
class TVG_API GlCanvas final : public Canvas
|
|
class TVG_API GlCanvas final : public Canvas
|
|
{
|
|
{
|
|
@@ -1576,7 +1702,7 @@ public:
|
|
*
|
|
*
|
|
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept;
|
|
Result target(uint32_t* buffer, uint32_t stride, uint32_t w, uint32_t h) noexcept;
|
|
|
|
|
|
@@ -1585,7 +1711,7 @@ public:
|
|
*
|
|
*
|
|
* @return A new GlCanvas object.
|
|
* @return A new GlCanvas object.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
static std::unique_ptr<GlCanvas> gen() noexcept;
|
|
static std::unique_ptr<GlCanvas> gen() noexcept;
|
|
|
|
|
|
@@ -1593,6 +1719,42 @@ public:
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * @class WgCanvas
|
|
|
|
+ *
|
|
|
|
+ * @brief A class for the rendering graphic elements with a WebGPU raster engine.
|
|
|
|
+ *
|
|
|
|
+ * @warning Please do not use it. This class is not fully supported yet.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+class TVG_API WgCanvas final : public Canvas
|
|
|
|
+{
|
|
|
|
+public:
|
|
|
|
+ ~WgCanvas();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Sets the target window for the rasterization.
|
|
|
|
+ *
|
|
|
|
+ * @warning Please do not use it, this API is not official one. It could be modified in the next version.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+ Result target(void* window, uint32_t w, uint32_t h) noexcept;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @brief Creates a new WgCanvas object.
|
|
|
|
+ *
|
|
|
|
+ * @return A new WgCanvas object.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+ static std::unique_ptr<WgCanvas> gen() noexcept;
|
|
|
|
+
|
|
|
|
+ _TVG_DECLARE_PRIVATE(WgCanvas);
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @class Initializer
|
|
* @class Initializer
|
|
*
|
|
*
|
|
@@ -1650,7 +1812,7 @@ public:
|
|
*
|
|
*
|
|
* This class supports the display and control of animation frames.
|
|
* This class supports the display and control of animation frames.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
|
|
|
|
class TVG_API Animation
|
|
class TVG_API Animation
|
|
@@ -1669,7 +1831,7 @@ public:
|
|
*
|
|
*
|
|
* @see totalFrame()
|
|
* @see totalFrame()
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
Result frame(float no) noexcept;
|
|
Result frame(float no) noexcept;
|
|
|
|
|
|
@@ -1684,7 +1846,7 @@ public:
|
|
*
|
|
*
|
|
* @warning The picture instance is owned by Animation. It should not be deleted manually.
|
|
* @warning The picture instance is owned by Animation. It should not be deleted manually.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
Picture* picture() const noexcept;
|
|
Picture* picture() const noexcept;
|
|
|
|
|
|
@@ -1698,7 +1860,7 @@ public:
|
|
* @see Animation::frame(float no)
|
|
* @see Animation::frame(float no)
|
|
* @see Animation::totalFrame()
|
|
* @see Animation::totalFrame()
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
float curFrame() const noexcept;
|
|
float curFrame() const noexcept;
|
|
|
|
|
|
@@ -1710,7 +1872,7 @@ public:
|
|
* @note Frame numbering starts from 0.
|
|
* @note Frame numbering starts from 0.
|
|
* @note If the Picture is not properly configured, this function will return 0.
|
|
* @note If the Picture is not properly configured, this function will return 0.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
float totalFrame() const noexcept;
|
|
float totalFrame() const noexcept;
|
|
|
|
|
|
@@ -1721,7 +1883,7 @@ public:
|
|
*
|
|
*
|
|
* @note If the Picture is not properly configured, this function will return 0.
|
|
* @note If the Picture is not properly configured, this function will return 0.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @% Experimental API
|
|
*/
|
|
*/
|
|
float duration() const noexcept;
|
|
float duration() const noexcept;
|
|
|
|
|
|
@@ -1730,7 +1892,7 @@ public:
|
|
*
|
|
*
|
|
* @return A new Animation object.
|
|
* @return A new Animation object.
|
|
*
|
|
*
|
|
- * @BETA_API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
static std::unique_ptr<Animation> gen() noexcept;
|
|
static std::unique_ptr<Animation> gen() noexcept;
|
|
|
|
|
|
@@ -1760,6 +1922,15 @@ class TVG_API Saver final
|
|
public:
|
|
public:
|
|
~Saver();
|
|
~Saver();
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @brief Sets the base background content for the saved image.
|
|
|
|
+ *
|
|
|
|
+ * @param[in] paint The paint to be drawn as the background image for the saving paint.
|
|
|
|
+ *
|
|
|
|
+ * @note Experimental API
|
|
|
|
+ */
|
|
|
|
+ Result background(std::unique_ptr<Paint> paint) noexcept;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @brief Exports the given @p paint data to the given @p path
|
|
* @brief Exports the given @p paint data to the given @p path
|
|
*
|
|
*
|
|
@@ -1794,18 +1965,18 @@ public:
|
|
* @param[in] quality The encoded quality level. @c 0 is the minimum, @c 100 is the maximum value(recommended).
|
|
* @param[in] quality The encoded quality level. @c 0 is the minimum, @c 100 is the maximum value(recommended).
|
|
* @param[in] fps The desired frames per second (FPS). For example, to encode data at 60 FPS, pass 60. Pass 0 to keep the original frame data.
|
|
* @param[in] fps The desired frames per second (FPS). For example, to encode data at 60 FPS, pass 60. Pass 0 to keep the original frame data.
|
|
*
|
|
*
|
|
- * @return Result::Success if the export succeeds.
|
|
|
|
- * @return Result::InsufficientCondition if there are ongoing resource-saving operations.
|
|
|
|
- * @return Result::NonSupport if an attempt is made to save the file with an unknown extension or in an unsupported format.
|
|
|
|
- * @return Result::MemoryCorruption in case of an internal error.
|
|
|
|
- * @return Result::Unknown if attempting to save an empty paint.
|
|
|
|
|
|
+ * @retval Result::Success if the export succeeds.
|
|
|
|
+ * @retval Result::InsufficientCondition if there are ongoing resource-saving operations.
|
|
|
|
+ * @retval Result::NonSupport if an attempt is made to save the file with an unknown extension or in an unsupported format.
|
|
|
|
+ * @retval Result::MemoryCorruption in case of an internal error.
|
|
|
|
+ * @retval Result::Unknown if attempting to save an empty paint.
|
|
*
|
|
*
|
|
* @note A higher frames per second (FPS) would result in a larger file size. It is recommended to use the default value.
|
|
* @note A higher frames per second (FPS) would result in a larger file size. It is recommended to use the default value.
|
|
* @note Saving can be asynchronous if the assigned thread number is greater than zero. To guarantee the saving is done, call sync() afterwards.
|
|
* @note Saving can be asynchronous if the assigned thread number is greater than zero. To guarantee the saving is done, call sync() afterwards.
|
|
*
|
|
*
|
|
* @see Saver::sync()
|
|
* @see Saver::sync()
|
|
*
|
|
*
|
|
- * @note: Experimental API
|
|
|
|
|
|
+ * @note Experimental API
|
|
*/
|
|
*/
|
|
Result save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0) noexcept;
|
|
Result save(std::unique_ptr<Animation> animation, const std::string& path, uint32_t quality = 100, uint32_t fps = 0) noexcept;
|
|
|
|
|
|
@@ -1882,7 +2053,7 @@ public:
|
|
* @brief The cast() function is a utility function used to cast a 'Paint' to type 'T'.
|
|
* @brief The cast() function is a utility function used to cast a 'Paint' to type 'T'.
|
|
* @since 0.11
|
|
* @since 0.11
|
|
*/
|
|
*/
|
|
-template<typename T>
|
|
|
|
|
|
+template<typename T = tvg::Paint>
|
|
std::unique_ptr<T> cast(Paint* paint)
|
|
std::unique_ptr<T> cast(Paint* paint)
|
|
{
|
|
{
|
|
return std::unique_ptr<T>(static_cast<T*>(paint));
|
|
return std::unique_ptr<T>(static_cast<T*>(paint));
|
|
@@ -1893,7 +2064,7 @@ std::unique_ptr<T> cast(Paint* paint)
|
|
* @brief The cast() function is a utility function used to cast a 'Fill' to type 'T'.
|
|
* @brief The cast() function is a utility function used to cast a 'Fill' to type 'T'.
|
|
* @since 0.11
|
|
* @since 0.11
|
|
*/
|
|
*/
|
|
-template<typename T>
|
|
|
|
|
|
+template<typename T = tvg::Fill>
|
|
std::unique_ptr<T> cast(Fill* fill)
|
|
std::unique_ptr<T> cast(Fill* fill)
|
|
{
|
|
{
|
|
return std::unique_ptr<T>(static_cast<T*>(fill));
|
|
return std::unique_ptr<T>(static_cast<T*>(fill));
|