MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / from_json

Method from_json

Source/NodeSerializer.cpp:86–110  ·  view source on GitHub ↗

untested

Source from the content-addressed store, hash-verified

84
85//untested
86void NodeSerializer::from_json(const ordered_json& j, ax::Node* p)
87{
88 p->setPosition({ j["pos"]["x"], j["pos"]["y"] });
89 p->setScaleX(j["scale"]["x"]);
90 p->setScaleY(j["scale"]["y"]);
91 p->setRotationSkewX(j["rot"]["x"]);
92 p->setRotationSkewY(j["rot"]["y"]);
93 p->setAnchorPoint({ j["anchor"]["x"], j["anchor"]["y"] });
94 p->setContentSize({ j["contentSize"]["width"], j["contentSize"]["height"] });
95 p->setColor({ j["color"]["r"], j["color"]["g"], j["color"]["b"] });
96 p->setGlobalZOrder(j["zOrder"]);
97 p->setVisible(j["visible"]);
98
99 const auto& childrenJson = j.find("children");
100 if (childrenJson != j.end()) {
101 const auto& childrenArray = *childrenJson;
102 for (const auto& childJson : childrenArray) {
103 ax::Node* child = nullptr;
104 from_json(childJson, child);
105 if (child) {
106 p->addChild(child);
107 }
108 }
109 }
110}
111
112void NodeSerializer::saveNodeToJsonFile(const std::string_view filename, ax::Node* rootNode)
113{

Callers

nothing calls this directly

Calls 6

from_jsonFunction · 0.85
setPositionMethod · 0.80
setScaleXMethod · 0.80
setScaleYMethod · 0.80
endMethod · 0.80
setColorMethod · 0.45

Tested by

no test coverage detected