mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 05:33:36 +00:00
svg_loader: Support percentage unit of dash-array
Refers to the diagonal length of the viewport. https://www.w3.org/TR/SVG2/coords.html#Units
This commit is contained in:
parent
1e1f232016
commit
ea3d79f5f3
1 changed files with 6 additions and 4 deletions
|
@ -244,7 +244,7 @@ _PARSE_TAG(FillRule, fillRule, FillRule, fillRuleTags, FillRule::Winding)
|
||||||
* https://www.w3.org/TR/SVG/painting.html
|
* https://www.w3.org/TR/SVG/painting.html
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
_parseDashArray(const char *str, SvgDash* dash)
|
_parseDashArray(SvgLoaderData* loader, const char *str, SvgDash* dash)
|
||||||
{
|
{
|
||||||
if (!strncmp(str, "none", 4)) return;
|
if (!strncmp(str, "none", 4)) return;
|
||||||
|
|
||||||
|
@ -257,7 +257,9 @@ _parseDashArray(const char *str, SvgDash* dash)
|
||||||
if (parsedValue <= 0.0f) break;
|
if (parsedValue <= 0.0f) break;
|
||||||
if (*end == '%') {
|
if (*end == '%') {
|
||||||
++end;
|
++end;
|
||||||
//TODO: multiply percentage value
|
//Refers to the diagonal length of the viewport.
|
||||||
|
//https://www.w3.org/TR/SVG2/coords.html#Units
|
||||||
|
parsedValue = (sqrt(pow(loader->svgParse->global.w, 2) + pow(loader->svgParse->global.h, 2)) / sqrt(2.0f)) * (parsedValue / 100.0f);
|
||||||
}
|
}
|
||||||
(*dash).array.push(parsedValue);
|
(*dash).array.push(parsedValue);
|
||||||
str = end;
|
str = end;
|
||||||
|
@ -815,10 +817,10 @@ static void _handleStrokeOpacityAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode*
|
||||||
node->style->stroke.opacity = _toOpacity(value);
|
node->style->stroke.opacity = _toOpacity(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _handleStrokeDashArrayAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node, const char* value)
|
static void _handleStrokeDashArrayAttr(SvgLoaderData* loader, SvgNode* node, const char* value)
|
||||||
{
|
{
|
||||||
node->style->stroke.flags = (SvgStrokeFlags)((int)node->style->stroke.flags | (int)SvgStrokeFlags::Dash);
|
node->style->stroke.flags = (SvgStrokeFlags)((int)node->style->stroke.flags | (int)SvgStrokeFlags::Dash);
|
||||||
_parseDashArray(value, &node->style->stroke.dash);
|
_parseDashArray(loader, value, &node->style->stroke.dash);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _handleStrokeWidthAttr(SvgLoaderData* loader, SvgNode* node, const char* value)
|
static void _handleStrokeWidthAttr(SvgLoaderData* loader, SvgNode* node, const char* value)
|
||||||
|
|
Loading…
Add table
Reference in a new issue