18 { u"frameWidth"_s, frameSize.width() },
19 { u"frameHeight"_s, frameSize.height() },
20 { u"patternX"_s, patternRect.x() },
21 { u"patternY"_s, patternRect.y() },
22 { u"patternWidth"_s, patternRect.width() },
23 { u"patternHeight"_s, patternRect.height() },
24 { u"backgroundColor"_s, backgroundColor.name(QColor::HexArgb) },
25 { u"firstColor"_s, firstColor.name(QColor::HexArgb) },
26 { u"secondColor"_s, secondColor.name(QColor::HexArgb) },
27 { u"animated"_s, animated },
28 { u"scale"_s, scale },
34 const auto intOr = [&](
const QString &key,
int fallback) {
35 const auto it = map.find(key);
36 return it == map.end() ? fallback : it->toInt();
38 const auto colorOr = [&](
const QString &key, QColor fallback) {
39 const auto it = map.find(key);
42 const QColor color(it->toString());
43 return color.isValid() ? color : fallback;
47 scene.frameSize = QSize(intOr(u"frameWidth"_s, scene.frameSize.width()),
48 intOr(u"frameHeight"_s, scene.frameSize.height()));
49 scene.patternRect = QRect(intOr(u"patternX"_s, scene.patternRect.x()),
50 intOr(u"patternY"_s, scene.patternRect.y()),
51 intOr(u"patternWidth"_s, scene.patternRect.width()),
52 intOr(u"patternHeight"_s, scene.patternRect.height()));
53 scene.backgroundColor = colorOr(u"backgroundColor"_s, scene.backgroundColor);
54 scene.firstColor = colorOr(u"firstColor"_s, scene.firstColor);
55 scene.secondColor = colorOr(u"secondColor"_s, scene.secondColor);
56 if (
const auto it = map.find(u"animated"_s); it != map.end())
58 if (
const auto it = map.find(u"scale"_s); it != map.end())
59 scene.scale = it->toReal();
65 QColor first = scene.firstColor;
66 QColor second = scene.secondColor;
67 if (scene.animated && (tick & 1u))
68 std::swap(first, second);
70 painter.fillRect(QRect(QPoint(0, 0), scene.frameSize), scene.backgroundColor);
71 painter.fillRect(scene.patternRect, first);
72 painter.fillRect(scene.insetRect(), second);