Compare commits

..

No commits in common. "5fbf46faf289dcd1f026f38003887bda82952e33" and "182284c60f0cd58a1986ec75e6928ca051ea64e1" have entirely different histories.

4 changed files with 325 additions and 248 deletions

413
4_L0.json
View File

@ -1,40 +1,33 @@
{ {
"background-color": "#ae9f86", "background-color": "#b7a386",
"elements": [ "elements": [
{ {
"data": { "data": {
"include": "/svg/2.svg" "include": "../svg/2.svg"
}, },
"name": "ababa", "name": "ababa",
"type": "svg-file" "type": "svg-file"
}, },
{ {
"data": { "data": {
"include": "/svg/0.svg" "reference-layer": "0.0"
},
"name": "ababa-group",
"type": "group"
},
{
"data": {
"include": "../svg/0.svg"
}, },
"name": "ababa2", "name": "ababa2",
"type": "svg-file" "type": "svg-file"
}, },
{ {
"data": { "data": {
"include": "/svg/4_L0.svg" "include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/4_L0.svg"
}, },
"name": "4_L0.svg", "name": "4_L0-fill.svg",
"type": "svg-file" "type": "svg-file"
},
{
"data": {
"reference-layer": "0.0"
},
"name": "图源工",
"type": "group"
},
{
"data": {
"reference-layer": "0.0"
},
"name": "图源万",
"type": "group"
} }
], ],
"height": 1080, "height": 1080,
@ -44,43 +37,41 @@
{ {
"children": [ "children": [
{ {
"children": [ "element": 3,
{
"element": 2,
"is-folder": false, "is-folder": false,
"name": "4_L0", "name": "4_L0",
"styles": [ "styles": [
{ {
"material": "AH8A/1JOff8=", "material": "AH8A/2pkiv8=",
"type": "fill" "type": "fill"
}, },
{ {
"enableEachSideIndependent": true, "enableEachSideIndependent": true,
"left": "AAAAQAEAJJwAf///9c19/w==", "left": "AADAQAEAJJwAf///9dKG/w==",
"right": "AADgQAAACpw=", "right": "AADgQAAACpw=",
"type": "stroke" "type": "stroke"
} }
], ],
"transform": { "transform": {
"offset": { "offset": {
"x": 0, "x": -230,
"y": 0 "y": -533
}, },
"rotation": 0, "rotation": 0,
"scale": { "scale": {
"x": 1, "x": 0.32341007644113307,
"y": 1 "y": 0.32341007644113307
} }
} }
} }
], ],
"is-folder": true, "is-folder": true,
"name": "工", "name": "GroupFolderExample",
"referenced-by": 3, "referenced-by": 1,
"transform": { "transform": {
"offset": { "offset": {
"x": 0, "x": 50,
"y": 0 "y": 50
}, },
"rotation": 0, "rotation": 0,
"scale": { "scale": {
@ -90,17 +81,53 @@
} }
}, },
{ {
"element": 3, "element": 1,
"is-folder": false, "is-folder": false,
"name": "1", "name": "aaaa2",
"styles": [
],
"transform": {
"offset": {
"x": 127,
"y": -109
},
"rotation": 90,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "aaaa3",
"styles": [
],
"transform": {
"offset": {
"x": 232,
"y": 17
},
"rotation": 180,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "aaaa4",
"styles": [ "styles": [
], ],
"transform": { "transform": {
"offset": { "offset": {
"x": 103, "x": 103,
"y": -1 "y": 130
}, },
"rotation": 90, "rotation": 270,
"scale": { "scale": {
"x": 1, "x": 1,
"y": 1 "y": 1
@ -108,15 +135,15 @@
} }
}, },
{ {
"element": 3, "element": 1,
"is-folder": false, "is-folder": false,
"name": "2", "name": "bbbb1",
"styles": [ "styles": [
], ],
"transform": { "transform": {
"offset": { "offset": {
"x": 104, "x": 197,
"y": 100 "y": 265
}, },
"rotation": 0, "rotation": 0,
"scale": { "scale": {
@ -126,15 +153,15 @@
} }
}, },
{ {
"element": 3, "element": 1,
"is-folder": false, "is-folder": false,
"name": "3", "name": "bbbb2",
"styles": [ "styles": [
], ],
"transform": { "transform": {
"offset": { "offset": {
"x": 3, "x": 323,
"y": 102 "y": 156
}, },
"rotation": 90, "rotation": 90,
"scale": { "scale": {
@ -142,11 +169,175 @@
"y": 1 "y": 1
} }
} }
} },
{
"element": 1,
"is-folder": false,
"name": "bbbb3",
"styles": [
],
"transform": {
"offset": {
"x": 432,
"y": 285
},
"rotation": 180,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "bbbb4",
"styles": [
],
"transform": {
"offset": {
"x": 302,
"y": 399
},
"rotation": 270,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "cccc1",
"styles": [
],
"transform": {
"offset": {
"x": 467,
"y": 71
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "cccc2",
"styles": [
],
"transform": {
"offset": {
"x": 361,
"y": -70
},
"rotation": 90,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "cccc3",
"styles": [
],
"transform": {
"offset": {
"x": 273,
"y": -211
},
"rotation": 180,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "cccc4",
"styles": [
],
"transform": {
"offset": {
"x": 574,
"y": 198
},
"rotation": 270,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "dddd1",
"styles": [
],
"transform": {
"offset": {
"x": 33,
"y": -231
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "dddd2",
"styles": [
],
"transform": {
"offset": {
"x": 55,
"y": 352
},
"rotation": 90,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "dddd3",
"styles": [
],
"transform": {
"offset": {
"x": -40,
"y": 220
},
"rotation": 180,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "dddd4",
"styles": [
], ],
"is-folder": true,
"name": "子图层-1",
"referenced-by": 4,
"transform": { "transform": {
"offset": { "offset": {
"x": 0, "x": 0,
@ -160,14 +351,14 @@
} }
}, },
{ {
"element": 4, "element": 1,
"is-folder": false, "is-folder": false,
"name": "子图层-2", "name": "eeee1",
"styles": [ "styles": [
], ],
"transform": { "transform": {
"offset": { "offset": {
"x": 204, "x": 0,
"y": 0 "y": 0
}, },
"rotation": 0, "rotation": 0,
@ -178,17 +369,17 @@
} }
}, },
{ {
"element": 4, "element": 1,
"is-folder": false, "is-folder": false,
"name": "子图层-3", "name": "eeee2",
"styles": [ "styles": [
], ],
"transform": { "transform": {
"offset": { "offset": {
"x": 3, "x": -149,
"y": 205 "y": 85
}, },
"rotation": 0, "rotation": 90,
"scale": { "scale": {
"x": 1, "x": 1,
"y": 1 "y": 1
@ -196,107 +387,17 @@
} }
}, },
{ {
"element": 4, "element": 1,
"is-folder": false, "is-folder": false,
"name": "子图层-4", "name": "eeee3",
"styles": [ "styles": [
], ],
"transform": { "transform": {
"offset": { "offset": {
"x": 207, "x": 166,
"y": 203 "y": 482
}, },
"rotation": 0, "rotation": 180,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 4,
"is-folder": false,
"name": "子图层-5",
"styles": [
],
"transform": {
"offset": {
"x": 407,
"y": -2
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 4,
"is-folder": false,
"name": "子图层-6",
"styles": [
],
"transform": {
"offset": {
"x": 411,
"y": 201
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 4,
"is-folder": false,
"name": "子图层-7",
"styles": [
],
"transform": {
"offset": {
"x": 6,
"y": 408
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 4,
"is-folder": false,
"name": "子图层-8",
"styles": [
],
"transform": {
"offset": {
"x": 210,
"y": 408
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 4,
"is-folder": false,
"name": "子图层-9",
"styles": [
],
"transform": {
"offset": {
"x": 414,
"y": 405
},
"rotation": 0,
"scale": { "scale": {
"x": 1, "x": 1,
"y": 1 "y": 1
@ -309,13 +410,13 @@
"referenced-by": null, "referenced-by": null,
"transform": { "transform": {
"offset": { "offset": {
"x": -9, "x": 8,
"y": -34 "y": 20
}, },
"rotation": 60, "rotation": 0,
"scale": { "scale": {
"x": 1, "x": 1.7159367435419115,
"y": 1 "y": 1.7159367435419115
} }
} }
}, },

View File

@ -114,22 +114,10 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const LayerSt
else else
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle))); maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio(); double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
if (painterPath == painterPathPrev && styles.getHash() == stylesHashValue)
{
transform.translate(movPrev.x(), movPrev.y());
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
painter->drawImage(0, 0, imagePrev);
}
else
{
auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, styles, pixelRatio); auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, styles, pixelRatio);
transform.translate(mov.x(), mov.y()); transform.translate(mov.x(), mov.y());
painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio)); painter->setTransform(transform.scale(1 / pixelRatio, 1 / pixelRatio));
painter->drawImage(0, 0, img); painter->drawImage(0, 0, img);
stylesHashValue = styles.getHash();
painterPathPrev = painterPath;
}
} }
painter->restore(); painter->restore();
} }

View File

@ -23,10 +23,6 @@ public:
size_t referencedCount = 0; size_t referencedCount = 0;
Renderer::ElementRenderer *renderer; Renderer::ElementRenderer *renderer;
QString name = ""; QString name = "";
size_t stylesHashValue;
QPainterPath painterPathPrev;
QPointF movPrev;
QImage imagePrev;
int index; int index;
// TODO: ¸ÄΪBitmapPath // TODO: ¸ÄΪBitmapPath
virtual QJsonObject toJson() const = 0; virtual QJsonObject toJson() const = 0;
@ -35,7 +31,6 @@ public:
virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0; virtual void paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles) = 0;
virtual bool isClosed() const = 0; virtual bool isClosed() const = 0;
virtual QPixmap getPreview(QSize size) = 0; virtual QPixmap getPreview(QSize size) = 0;
}; };
class SimpleElement : public GraphicElement class SimpleElement : public GraphicElement

View File

@ -1,11 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 141 171">
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <title>4_L0的副本</title>
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" <polygon points="0.5 0.5 140.5 0.5 140.5 10.5 115.5 10.5 115.5 35.5 105.5 35.5 105.5 10.5 75.5 10.5 75.5 160.5 105.5 160.5 105.5 135.5 115.5 135.5 115.5 160.5 140.5 160.5 140.5 170.5 0.5 170.5 0.5 160.5 25.5 160.5 25.5 135.5 35.5 135.5 35.5 160.5 65.5 160.5 65.5 10.5 35.5 10.5 35.5 35.5 25.5 35.5 25.5 10.5 0.5 10.5 0.5 0.5" fill="none" stroke="#000" stroke-miterlimit="10"/>
viewBox="0 0 141 171" style="enable-background:new 0 0 141 171;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#000000;stroke-miterlimit:10;}
</style>
<polygon class="st0" points="0.5,0.5 140.5,0.5 140.5,10.5 115.5,10.5 115.5,31.5 105.5,31.5 105.5,10.5 75.5,10.5 75.5,165.8
105.5,165.8 105.5,144.7 115.5,144.7 115.5,165.8 140.5,165.8 140.5,175.8 0.5,175.8 0.5,165.8 25.5,165.8 25.5,144.7 35.5,144.7
35.5,165.8 65.5,165.8 65.5,10.5 35.5,10.5 35.5,31.5 25.5,31.5 25.5,10.5 0.5,10.5 "/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 781 B

After

Width:  |  Height:  |  Size: 480 B