mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
tvg: support stroke miterlimit property.
implement the miterlimit property that was introduced by
44a750ee5d
@Issue: https://github.com/thorvg/thorvg/issues/1490
This commit is contained in:
parent
f9816a9e6f
commit
075e3e6b2a
3 changed files with 19 additions and 2 deletions
|
@ -71,14 +71,16 @@ using TvgBinFlag = TvgBinByte;
|
|||
#define TVG_TAG_SHAPE_FILL (TvgBinTag)0x42
|
||||
#define TVG_TAG_SHAPE_COLOR (TvgBinTag)0x43
|
||||
#define TVG_TAG_SHAPE_FILLRULE (TvgBinTag)0x44
|
||||
#define TVG_TAG_SHAPE_STROKE_CAP (TvgBinTag)0x50
|
||||
#define TVG_TAG_SHAPE_STROKE_JOIN (TvgBinTag)0x51
|
||||
|
||||
|
||||
//Stroke
|
||||
#define TVG_TAG_SHAPE_STROKE_CAP (TvgBinTag)0x50
|
||||
#define TVG_TAG_SHAPE_STROKE_JOIN (TvgBinTag)0x51
|
||||
#define TVG_TAG_SHAPE_STROKE_WIDTH (TvgBinTag)0x52
|
||||
#define TVG_TAG_SHAPE_STROKE_COLOR (TvgBinTag)0x53
|
||||
#define TVG_TAG_SHAPE_STROKE_FILL (TvgBinTag)0x54
|
||||
#define TVG_TAG_SHAPE_STROKE_DASHPTRN (TvgBinTag)0x55
|
||||
#define TVG_TAG_SHAPE_STROKE_MITERLIMIT (TvgBinTag)0x56
|
||||
|
||||
|
||||
//Fill
|
||||
|
|
|
@ -309,6 +309,13 @@ static bool _parseShapeStroke(const char *ptr, const char *end, Shape *shape)
|
|||
if (!_parseShapeStrokeDashPattern(block.data, block.end, shape)) return false;
|
||||
break;
|
||||
}
|
||||
case TVG_TAG_SHAPE_STROKE_MITERLIMIT: {
|
||||
if (block.length != SIZE(float)) return false;
|
||||
float miterlimit;
|
||||
READ_FLOAT(&miterlimit, block.data);
|
||||
shape->strokeMiterlimit(miterlimit);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
TVGLOG("TVG", "Unsupported tag %d (0x%x) used as one of stroke properties, %d bytes skipped", block.type, block.type, block.length);
|
||||
break;
|
||||
|
|
|
@ -115,6 +115,8 @@ static bool _merge(Shape* from, Shape* to)
|
|||
if (from->strokeDash(nullptr) > 0 || to->strokeDash(nullptr) > 0) return false;
|
||||
if (from->strokeFill() || to->strokeFill()) return false;
|
||||
|
||||
if (fabsf(from->strokeMiterlimit() - to->strokeMiterlimit()) > FLT_EPSILON) return false;
|
||||
|
||||
//fill rule
|
||||
if (from->fillRule() != to->fillRule()) return false;
|
||||
|
||||
|
@ -476,6 +478,12 @@ TvgBinCounter TvgSaver::serializeStroke(const Shape* shape, const Matrix* pTrans
|
|||
cnt += SIZE(TvgBinTag) + SIZE(TvgBinCounter);
|
||||
}
|
||||
|
||||
//miterlimit (the default value is 4)
|
||||
auto miterlimit = shape->strokeMiterlimit();
|
||||
if (fabsf(miterlimit - 4.0f) > FLT_EPSILON) {
|
||||
cnt += writeTagProperty(TVG_TAG_SHAPE_STROKE_MITERLIMIT, SIZE(miterlimit), &miterlimit);
|
||||
}
|
||||
|
||||
writeReservedCount(cnt);
|
||||
|
||||
return SERIAL_DONE(cnt);
|
||||
|
|
Loading…
Add table
Reference in a new issue