Result load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept;
/**
+ * @brief Gets the position and the size of the loaded SVG picture.
+ *
+ * @warning Please do not use it, this API is not official one. It could be modified in the next version.
+ *
+ * @BETA_API
+ */
+ Result viewbox(float* x, float* y, float* w, float* h) const noexcept;
+
+ /**
* @brief Creates a new Picture object.
*
* @return A new Picture object.
TVG_EXPORT Tvg_Result tvg_picture_get_size(const Tvg_Paint* paint, float* w, float* h);
+/*!
+* \brief Gets the position and the size of the loaded picture. (BETA version)
+*
+* \warning Please do not use it, this API is not official one. It can be modified in the next version.
+*/
+TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h);
+
+
/** \} */ // end defgroup ThorVGCapi_Picture
return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->size(w, h);
}
+
+TVG_EXPORT Tvg_Result tvg_picture_get_viewbox(const Tvg_Paint* paint, float* x, float* y, float* w, float* h)
+{
+ if (!paint) return TVG_RESULT_INVALID_ARGUMENT;
+ return (Tvg_Result) reinterpret_cast<Picture*>(CCP(paint))->viewbox(x, y, w, h);
+}
+
/************************************************************************/
/* Gradient API */
/************************************************************************/
class LoadModule
{
public:
+ //default view box, if any.
+ float vx = 0;
+ float vy = 0;
+ float vw = 0;
+ float vh = 0;
float w = 0, h = 0; //default image size
+ bool preserveAspect = true; //keep aspect ratio by default.
virtual ~LoadModule() {}
}
+Result Picture::viewbox(float* x, float* y, float* w, float* h) const noexcept
+{
+ if (pImpl->viewbox(x, y, w, h)) return Result::Success;
+ return Result::InsufficientCondition;
+}
+
+
Result Picture::size(float w, float h) noexcept
{
if (pImpl->size(w, h)) return Result::Success;
return false;
}
+ bool viewbox(float* x, float* y, float* w, float* h) const
+ {
+ if (!loader) return false;
+ if (x) *x = loader->vx;
+ if (y) *y = loader->vy;
+ if (w) *w = loader->vw;
+ if (h) *h = loader->vh;
+ return true;
+ }
+
bool size(uint32_t w, uint32_t h)
{
this->w = w;
SvgLoaderData loaderData;
unique_ptr<Scene> root;
- //default view box, if any.
- float vx = 0;
- float vy = 0;
- float vw = 0;
- float vh = 0;
-
bool copy = false;
- bool preserveAspect = true; //aspect ratio option
SvgLoader();
~SvgLoader();