1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "bmfill_p.h"
5
6QT_BEGIN_NAMESPACE
7
8BMFill::BMFill(const BMFill &other)
9 : BMShape(other)
10{
11 m_color = other.m_color;
12 m_opacity = other.m_opacity;
13}
14
15BMFill::BMFill(const QJsonObject &definition, const QVersionNumber &version, BMBase *parent)
16{
17 setParent(parent);
18 BMBase::parse(definition);
19 if (m_hidden)
20 return;
21
22 qCDebug(lcLottieQtBodymovinParser) << "BMFill::construct():" << m_name;
23
24 QJsonObject color = definition.value(key: QLatin1String("c")).toObject();
25 m_color.construct(definition: color, version);
26
27 QJsonObject opacity = definition.value(key: QLatin1String("o")).toObject();
28 opacity = resolveExpression(definition: opacity);
29 m_opacity.construct(definition: opacity, version);
30}
31
32BMBase *BMFill::clone() const
33{
34 return new BMFill(*this);
35}
36
37void BMFill::updateProperties(int frame)
38{
39 m_color.update(frame);
40 m_opacity.update(frame);
41}
42
43void BMFill::render(LottieRenderer &renderer) const
44{
45 renderer.render(fill: *this);
46}
47
48QColor BMFill::color() const
49{
50 QVector4D cVec = m_color.value();
51 QColor color;
52 qreal r = static_cast<qreal>(cVec.x());
53 qreal g = static_cast<qreal>(cVec.y());
54 qreal b = static_cast<qreal>(cVec.z());
55 qreal a = static_cast<qreal>(cVec.w());
56 color.setRgbF(r, g, b, a);
57 return color;
58}
59
60qreal BMFill::opacity() const
61{
62 return m_opacity.value();
63}
64
65QT_END_NAMESPACE
66

source code of qtlottie/src/bodymovin/bmfill.cpp