#ifndef Trim_hpp #define Trim_hpp #include "Lottie/Private/Model/ShapeItems/ShapeItem.hpp" #include "Lottie/Private/Model/Keyframes/KeyframeGroup.hpp" #include #include "Lottie/Private/Parsing/JsonParsing.hpp" namespace lottie { /// An item that defines trim class Trim: public ShapeItem { public: explicit Trim(lottiejson11::Json::object const &json) noexcept(false) : ShapeItem(json), start(KeyframeGroup(Vector1D(0.0))), end(KeyframeGroup(Vector1D(0.0))), offset(KeyframeGroup(Vector1D(0.0))), trimType(TrimType::Simultaneously) { start = KeyframeGroup(getObject(json, "s")); end = KeyframeGroup(getObject(json, "e")); offset = KeyframeGroup(getObject(json, "o")); auto trimTypeRawValue = getInt(json, "m"); switch (trimTypeRawValue) { case 1: trimType = TrimType::Simultaneously; break; case 2: trimType = TrimType::Individually; break; default: throw LottieParsingException(); } } virtual ~Trim() = default; virtual void toJson(lottiejson11::Json::object &json) const override { ShapeItem::toJson(json); json.insert(std::make_pair("s", start.toJson())); json.insert(std::make_pair("e", end.toJson())); json.insert(std::make_pair("o", offset.toJson())); json.insert(std::make_pair("m", (int)trimType)); } public: KeyframeGroup start; KeyframeGroup end; KeyframeGroup offset; TrimType trimType; }; } #endif /* Trim_hpp */