mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 06:04:03 +00:00
lottie: code clean up
This commit is contained in:
parent
4f2e725da0
commit
c75ec0f333
3 changed files with 20 additions and 24 deletions
|
@ -985,7 +985,7 @@ void LottieBuilder::updateImage(LottieGroup* layer)
|
||||||
void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
||||||
{
|
{
|
||||||
auto text = static_cast<LottieText*>(layer->children.first());
|
auto text = static_cast<LottieText*>(layer->children.first());
|
||||||
auto textGrouping = text->alignmentOption.grouping;
|
auto textGrouping = text->alignOption.grouping;
|
||||||
auto& doc = text->doc(frameNo);
|
auto& doc = text->doc(frameNo);
|
||||||
auto p = doc.text;
|
auto p = doc.text;
|
||||||
|
|
||||||
|
@ -1127,7 +1127,7 @@ void LottieBuilder::updateText(LottieLayer* layer, float frameNo)
|
||||||
identity(&textGroupMatrix);
|
identity(&textGroupMatrix);
|
||||||
translate(&textGroupMatrix, cursor.x, cursor.y);
|
translate(&textGroupMatrix, cursor.x, cursor.y);
|
||||||
|
|
||||||
auto alignment = text->alignmentOption.anchor(frameNo);
|
auto alignment = text->alignOption.anchor(frameNo);
|
||||||
|
|
||||||
// center pivoting
|
// center pivoting
|
||||||
textGroupMatrix.e13 += alignment.x;
|
textGroupMatrix.e13 += alignment.x;
|
||||||
|
|
|
@ -179,8 +179,13 @@ struct LottieGlyph
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct LottieTextStyle
|
struct LottieTextRange
|
||||||
{
|
{
|
||||||
|
enum Based : uint8_t { Chars = 1, CharsExcludingSpaces, Words, Lines };
|
||||||
|
enum Shape : uint8_t { Square = 1, RampUp, RampDown, Triangle, Round, Smooth };
|
||||||
|
enum Unit : uint8_t { Percent = 1, Index };
|
||||||
|
|
||||||
|
struct {
|
||||||
LottieColor fillColor = RGB24{255, 255, 255};
|
LottieColor fillColor = RGB24{255, 255, 255};
|
||||||
LottieColor strokeColor = RGB24{255, 255, 255};
|
LottieColor strokeColor = RGB24{255, 255, 255};
|
||||||
LottiePosition position = Point{0, 0};
|
LottiePosition position = Point{0, 0};
|
||||||
|
@ -192,16 +197,8 @@ struct LottieTextStyle
|
||||||
LottieOpacity fillOpacity = 255;
|
LottieOpacity fillOpacity = 255;
|
||||||
LottieOpacity strokeOpacity = 255;
|
LottieOpacity strokeOpacity = 255;
|
||||||
LottieOpacity opacity = 255;
|
LottieOpacity opacity = 255;
|
||||||
};
|
} style;
|
||||||
|
|
||||||
|
|
||||||
struct LottieTextRange
|
|
||||||
{
|
|
||||||
enum Based : uint8_t { Chars = 1, CharsExcludingSpaces, Words, Lines };
|
|
||||||
enum Shape : uint8_t { Square = 1, RampUp, RampDown, Triangle, Round, Smooth };
|
|
||||||
enum Unit : uint8_t { Percent = 1, Index };
|
|
||||||
|
|
||||||
LottieTextStyle style;
|
|
||||||
LottieFloat offset = 0.0f;
|
LottieFloat offset = 0.0f;
|
||||||
LottieFloat maxEase = 0.0f;
|
LottieFloat maxEase = 0.0f;
|
||||||
LottieFloat minEase = 0.0f;
|
LottieFloat minEase = 0.0f;
|
||||||
|
@ -257,8 +254,8 @@ struct LottieText : LottieObject, LottieRenderPooler<tvg::Shape>
|
||||||
{
|
{
|
||||||
enum Group : uint8_t { Chars = 1, Word = 2, Line = 3, All = 4 };
|
enum Group : uint8_t { Chars = 1, Word = 2, Line = 3, All = 4 };
|
||||||
Group grouping = Chars;
|
Group grouping = Chars;
|
||||||
LottiePoint anchor = Point{0.0f, 0.0f};
|
LottiePoint anchor{};
|
||||||
};
|
} alignOption;
|
||||||
|
|
||||||
void prepare()
|
void prepare()
|
||||||
{
|
{
|
||||||
|
@ -280,7 +277,6 @@ struct LottieText : LottieObject, LottieRenderPooler<tvg::Shape>
|
||||||
LottieTextDoc doc;
|
LottieTextDoc doc;
|
||||||
LottieFont* font;
|
LottieFont* font;
|
||||||
Array<LottieTextRange*> ranges;
|
Array<LottieTextRange*> ranges;
|
||||||
AlignOption alignmentOption;
|
|
||||||
|
|
||||||
~LottieText()
|
~LottieText()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1133,8 +1133,8 @@ void LottieParser::parseTextAlignmentOption(LottieText* text)
|
||||||
{
|
{
|
||||||
enterObject();
|
enterObject();
|
||||||
while (auto key = nextObjectKey()) {
|
while (auto key = nextObjectKey()) {
|
||||||
if (KEY_AS("g")) text->alignmentOption.grouping = (LottieText::AlignOption::Group) getInt();
|
if (KEY_AS("g")) text->alignOption.grouping = (LottieText::AlignOption::Group) getInt();
|
||||||
else if (KEY_AS("a")) parseProperty<LottieProperty::Type::Point>(text->alignmentOption.anchor);
|
else if (KEY_AS("a")) parseProperty<LottieProperty::Type::Point>(text->alignOption.anchor);
|
||||||
else skip(key);
|
else skip(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue