You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: thirdparty/thorvg/inc/thorvg.h
+72-78
Original file line number
Diff line number
Diff line change
@@ -157,15 +157,17 @@ enum class FillRule
157
157
enumclassCompositeMethod
158
158
{
159
159
None = 0, ///< No composition is applied.
160
-
ClipPath, ///< The intersection of the source and the target is determined and only the resulting pixels from the source are rendered.
160
+
ClipPath, ///< The intersection of the source and the target is determined and only the resulting pixels from the source are rendered. Note that ClipPath only supports the Shape type.
161
161
AlphaMask, ///< Alpha Masking using the compositing target's pixels as an alpha value.
162
162
InvAlphaMask, ///< Alpha Masking using the complement to the compositing target's pixels as an alpha value.
163
163
LumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the compositing target's pixels. @since 0.9
164
164
InvLumaMask, ///< Alpha Masking using the grayscale (0.2125R + 0.7154G + 0.0721*B) of the complement to the compositing target's pixels. @since 0.11
165
165
AddMask, ///< Combines the target and source objects pixels using target alpha. (T * TA) + (S * (255 - TA)) (Experimental API)
166
166
SubtractMask, ///< Subtracts the source color from the target color while considering their respective target alpha. (T * TA) - (S * (255 - TA)) (Experimental API)
167
167
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)
168
-
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)
168
+
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)
169
+
LightenMask, ///< Where multiple masks intersect, the highest transparency value is used. (Experimental API)
170
+
DarkenMask ///< Where multiple masks intersect, the lowest transparency value is used. (Experimental API)
169
171
};
170
172
171
173
@@ -232,34 +234,6 @@ struct Matrix
232
234
};
233
235
234
236
235
-
/**
236
-
* @brief A data structure representing a texture mesh vertex
237
-
*
238
-
* @param pt The vertex coordinate
239
-
* @param uv The normalized texture coordinate in the range (0.0..1.0, 0.0..1.0)
240
-
*
241
-
* @note Experimental API
242
-
*/
243
-
structVertex
244
-
{
245
-
Point pt;
246
-
Point uv;
247
-
};
248
-
249
-
250
-
/**
251
-
* @brief A data structure representing a triange in a texture mesh
252
-
*
253
-
* @param vertex The three vertices that make up the polygon
254
-
*
255
-
* @note Experimental API
256
-
*/
257
-
structPolygon
258
-
{
259
-
Vertex vertex[3];
260
-
};
261
-
262
-
263
237
/**
264
238
* @class Paint
265
239
*
@@ -361,7 +335,7 @@ class TVG_API Paint
361
335
*
362
336
* @note Experimental API
363
337
*/
364
-
Result blend(BlendMethod method) constnoexcept;
338
+
Result blend(BlendMethod method) noexcept;
365
339
366
340
/**
367
341
* @deprecated Use bounds(float* x, float* y, float* w, float* h, bool transformed) instead
@@ -371,15 +345,16 @@ class TVG_API Paint
371
345
/**
372
346
* @brief Gets the axis-aligned bounding box of the paint object.
373
347
*
374
-
* In case @p transform is @c true, all object's transformations are applied first, and then the bounding box is established. Otherwise, the bounding box is determined before any transformations.
375
-
*
376
-
* @param[out] x The x coordinate of the upper left corner of the object.
377
-
* @param[out] y The y coordinate of the upper left corner of the object.
348
+
* @param[out] x The x-coordinate of the upper-left corner of the object.
349
+
* @param[out] y The y-coordinate of the upper-left corner of the object.
378
350
* @param[out] w The width of the object.
379
351
* @param[out] h The height of the object.
380
-
* @param[in] transformed If @c true, the paint's transformations are taken into account, otherwise they aren't.
352
+
* @param[in] transformed If @c true, the paint's transformations are taken into account in the scene it belongs to. Otherwise they aren't.
381
353
*
354
+
* @note This is useful when you need to figure out the bounding box of the paint in the canvas space.
382
355
* @note The bounding box doesn't indicate the actual drawing region. It's the smallest rectangle that encloses the object.
356
+
* @note If @p transformed is @c true, the paint needs to be pushed into a canvas and updated before this api is called.
357
+
* @see Canvas::update()
383
358
*/
384
359
Result bounds(float* x, float* y, float* w, float* h, bool transformed) constnoexcept;
* @brief Retrieves the current blending method applied to the paint object.
415
390
*
416
-
* @return The blending method
391
+
* @return The currently set blending method.
417
392
*
418
393
* @note Experimental API
419
394
*/
@@ -428,6 +403,15 @@ class TVG_API Paint
428
403
*/
429
404
uint32_tidentifier() constnoexcept;
430
405
406
+
/**
407
+
* @brief Unique ID of this instance.
408
+
*
409
+
* This is reserved to specify an paint instance in a scene.
410
+
*
411
+
* @since Experimental API
412
+
*/
413
+
uint32_t id = 0;
414
+
431
415
_TVG_DECLARE_PRIVATE(Paint);
432
416
};
433
417
@@ -675,7 +659,8 @@ class TVG_API LinearGradient final : public Fill
675
659
* @param[in] x2 The horizontal coordinate of the second point used to determine the gradient bounds.
676
660
* @param[in] y2 The vertical coordinate of the second point used to determine the gradient bounds.
677
661
*
678
-
* @note In case the first and the second points are equal, an object filled with such a gradient fill is not rendered.
662
+
* @note In case the first and the second points are equal, an object is filled with a single color using the last color specified in the colorStops().
663
+
* @see Fill::colorStops()
679
664
*/
680
665
Result linear(float x1, float y1, float x2, float y2) noexcept;
681
666
@@ -734,6 +719,8 @@ class TVG_API RadialGradient final : public Fill
734
719
* @param[in] radius The radius of the bounding circle.
735
720
*
736
721
* @retval Result::InvalidArguments in case the @p radius value is zero or less.
722
+
*
723
+
* @note In case the @p radius is zero, an object is filled with a single color using the last color specified in the colorStops().
737
724
*/
738
725
Result radial(float cx, float cy, float radius) noexcept;
739
726
@@ -990,7 +977,7 @@ class TVG_API Shape final : public Paint
990
977
/**
991
978
* @brief Sets the trim of the stroke along the defined path segment, allowing control over which part of the stroke is visible.
992
979
*
993
-
* The values of the arguments @p begin, @p end, and @p offset are in the range of 0.0 to 1.0, representing the beginning of the path and the end, respectively.
980
+
* If the values of the arguments @p beginand @p end exceed the 0-1 range, they are wrapped around in a manner similar to angle wrapping, effectively treating the range as circular.
994
981
*
995
982
* @param[in] begin Specifies the start of the segment to display along the path.
996
983
* @param[in] end Specifies the end of the segment to display along the path.
@@ -1076,7 +1063,6 @@ class TVG_API Shape final : public Paint
1076
1063
* @param[out] b The blue color channel value in the range [0 ~ 255].
1077
1064
* @param[out] a The alpha channel value in the range [0 ~ 255], where 0 is completely transparent and 255 is opaque.
1078
1065
*
1079
-
* @return Result::Success when succeed.
1080
1066
*/
1081
1067
Result fillColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a = nullptr) constnoexcept;
1082
1068
@@ -1219,7 +1205,7 @@ class TVG_API Picture final : public Paint
1219
1205
* when the @p copy has @c false. This means that loading the same data again will not result in duplicate operations
1220
1206
* for the sharable @p data. Instead, ThorVG will reuse the previously loaded picture data.
1221
1207
*
1222
-
* @param[in] data A pointer to a memory location where the content of the picture file is stored.
1208
+
* @param[in] data A pointer to a memory location where the content of the picture file is stored. A null-terminated string is expected for non-binary data if @p copy is @c false.
1223
1209
* @param[in] size The size in bytes of the memory occupied by the @p data.
1224
1210
* @param[in] mimeType Mimetype or extension of data such as "jpg", "jpeg", "lottie", "svg", "svg+xml", "png", etc. In case an empty string or an unknown type is provided, the loaders will be tried one by one.
1225
1211
* @param[in] copy If @c true the data are copied into the engine local buffer, otherwise they are not.
@@ -1256,7 +1242,7 @@ class TVG_API Picture final : public Paint
1256
1242
Result size(float* w, float* h) constnoexcept;
1257
1243
1258
1244
/**
1259
-
* @brief Loads a raw data from a memory block with a given size.
1245
+
* @brief Loads raw data in ARGB8888 format from a memory block of the given size.
1260
1246
*
1261
1247
* ThorVG efficiently caches the loaded data using the specified @p data address as a key
1262
1248
* when the @p copy has @c false. This means that loading the same data again will not result in duplicate operations
@@ -1265,47 +1251,27 @@ class TVG_API Picture final : public Paint
1265
1251
* @param[in] data A pointer to a memory location where the content of the picture raw data is stored.
1266
1252
* @param[in] w The width of the image @p data in pixels.
1267
1253
* @param[in] h The height of the image @p data in pixels.
1268
-
* @param[in] premultiplied If @c true, the given image data is alpha-premultiplied.
1269
1254
* @param[in] copy If @c true the data are copied into the engine local buffer, otherwise they are not.
1270
1255
*
1256
+
* @note It expects premultiplied alpha data.
1271
1257
* @since 0.9
1272
1258
*/
1273
1259
Result load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept;
1274
1260
1275
1261
/**
1276
-
* @brief Sets or removes the triangle mesh to deform the image.
1277
-
*
1278
-
* If a mesh is provided, the transform property of the Picture will apply to the triangle mesh, and the
1279
-
* image data will be used as the texture.
1280
-
*
1281
-
* If @p triangles is @c nullptr, or @p triangleCnt is 0, the mesh will be removed.
1282
-
*
1283
-
* Only raster image types are supported at this time (png, jpg). Vector types like svg and tvg do not support.
1284
-
* mesh deformation. However, if required you should be able to render a vector image to a raster image and then apply a mesh.
1262
+
* @brief Retrieve a paint object from the Picture scene by its Unique ID.
1285
1263
*
1286
-
* @param[in] triangles An array of Polygons(triangles) that make up the mesh, or null to remove the mesh.
1287
-
* @param[in] triangleCnt The number of Polygons(triangles) provided, or 0 to remove the mesh.
1264
+
* This function searches for a paint object within the Picture scene that matches the provided @p id.
1288
1265
*
1289
-
* @note The Polygons are copied internally, so modifying them after calling Mesh::mesh has no affect.
1290
-
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
1266
+
* @param[in] id The Unique ID of the paint object.
1291
1267
*
1292
-
* @note Experimental API
1293
-
*/
1294
-
Result mesh(const Polygon* triangles, uint32_t triangleCnt) noexcept;
1295
-
1296
-
/**
1297
-
* @brief Return the number of triangles in the mesh, and optionally get a pointer to the array of triangles in the mesh.
1268
+
* @return A pointer to the paint object that matches the given identifier, or @c nullptr if no matching paint object is found.
1298
1269
*
1299
-
* @param[out] triangles Optional. A pointer to the array of Polygons used by this mesh.
1300
-
*
1301
-
* @return The number of polygons in the array.
1302
-
*
1303
-
* @note Modifying the triangles returned by this method will modify them directly within the mesh.
1304
-
* @warning Please do not use it, this API is not official one. It could be modified in the next version.
0 commit comments