karlis 2023-03-20 22:27:04 +08:00
commit 826a8d3e2e
9 changed files with 447 additions and 20 deletions

424
4_L0.json Normal file
View File

@ -0,0 +1,424 @@
{
"background-color": "#b7a386",
"elements": [
{
"data": {
"include": "../svg/2.svg"
},
"name": "ababa",
"type": "svg-file"
},
{
"data": {
"reference-layer": "0.0"
},
"name": "ababa-group",
"type": "group"
},
{
"data": {
"include": "../svg/0.svg"
},
"name": "ababa2",
"type": "svg-file"
},
{
"data": {
"include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/4_L0-fill.svg"
},
"name": "4_L0-fill.svg",
"type": "svg-file"
}
],
"height": 1080,
"project-name": "样例1",
"root-layer": {
"children": [
{
"children": [
{
"element": 3,
"is-folder": false,
"name": "4_L0",
"styles": [
{
"material": "AH8A/2pkiv8=",
"type": "fill"
},
{
"enableEachSideIndependent": true,
"left": "AADAQAEAJJwAf///9dKG/w==",
"right": "AADgQAAACpw=",
"type": "stroke"
}
],
"transform": {
"offset": {
"x": -230,
"y": -533
},
"rotation": 0,
"scale": {
"x": 0.32341007644113307,
"y": 0.32341007644113307
}
}
}
],
"is-folder": true,
"name": "GroupFolderExample",
"referenced-by": 1,
"transform": {
"offset": {
"x": 50,
"y": 50
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"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": [
],
"transform": {
"offset": {
"x": 103,
"y": 130
},
"rotation": 270,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "bbbb1",
"styles": [
],
"transform": {
"offset": {
"x": 197,
"y": 265
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "bbbb2",
"styles": [
],
"transform": {
"offset": {
"x": 323,
"y": 156
},
"rotation": 90,
"scale": {
"x": 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": [
],
"transform": {
"offset": {
"x": 0,
"y": 0
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "eeee1",
"styles": [
],
"transform": {
"offset": {
"x": 0,
"y": 0
},
"rotation": 0,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "eeee2",
"styles": [
],
"transform": {
"offset": {
"x": -149,
"y": 85
},
"rotation": 90,
"scale": {
"x": 1,
"y": 1
}
}
},
{
"element": 1,
"is-folder": false,
"name": "eeee3",
"styles": [
],
"transform": {
"offset": {
"x": 166,
"y": 482
},
"rotation": 180,
"scale": {
"x": 1,
"y": 1
}
}
}
],
"is-folder": true,
"name": "root",
"referenced-by": null,
"transform": {
"offset": {
"x": 8,
"y": 20
},
"rotation": 0,
"scale": {
"x": 1.7159367435419115,
"y": 1.7159367435419115
}
}
},
"width": 1080
}

View File

@ -1409,7 +1409,7 @@ void main()
imageStore(gBaseColor, pixelLocation, vec4(color.rgb, 1)); imageStore(gBaseColor, pixelLocation, vec4(color.rgb, 1));
imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1)); imageStore(gMetallicRoughness, pixelLocation, vec4(metallicRoughness, 0, 1));
//return; return;
if (/*color.a!=-1&&*/ debugBVH == vec3(0)) if (/*color.a!=-1&&*/ debugBVH == vec3(0))
{ {
// imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1)); // imageStore(gBaseColor, pixelLocation, vec4(vec3(1, 1, 0),1));

View File

@ -1,6 +1,4 @@
#include "ColorPicker.h" #include "ColorPicker.h"
#include <QColorDialog>
#include <QDebug>
QString getStyleSheet(const QColor& color) QString getStyleSheet(const QColor& color)
{ {
@ -27,7 +25,6 @@ QColor ColorPicker::getColor() const
void ColorPicker::onClicked() void ColorPicker::onClicked()
{ {
//const QColor newColor = QColorDialog::getColor(this->color, this);
const QColor newColor = ColorHelper::execColorDialog(this->color, this); const QColor newColor = ColorHelper::execColorDialog(this->color, this);
if (newColor.isValid() && this->color != newColor) if (newColor.isValid() && this->color != newColor)
{ {

View File

@ -4,6 +4,7 @@
#include <qtmaterialraisedbutton.h> #include <qtmaterialraisedbutton.h>
#include <limits> #include <limits>
#include <array> #include <array>
#include <QHeaderView>
#include <ranges> #include <ranges>
#include <utility> #include <utility>
@ -28,12 +29,6 @@ StrokeStyleWidget::StrokeStyleWidget(
QWidget* parent QWidget* parent
) : QWidget(parent), stroke(stroke) ) : QWidget(parent), stroke(stroke)
{ {
auto& materialMap = radialStroke(stroke)->materialMap;
if (materialMap.empty())
{
materialMap[1.f] = newMaterial();
}
auto* viewLayout = new QVBoxLayout(this); auto* viewLayout = new QVBoxLayout(this);
this->setLayout(viewLayout); this->setLayout(viewLayout);
@ -115,7 +110,7 @@ void StrokeStyleWidget::initTable(const std::shared_ptr<Renderer::StrokeRadialGr
<< QStringLiteral("´Ö²Ú¶È") << QStringLiteral("´Ö²Ú¶È")
<< QStringLiteral("ÆäËû²Ù×÷"); << QStringLiteral("ÆäËû²Ù×÷");
strokeTable->setHorizontalHeaderLabels(headers); strokeTable->setHorizontalHeaderLabels(headers);
strokeTable->setMinimumHeight(strokeTable->rowHeight(0) * 5); strokeTable->setMinimumHeight(strokeTable->horizontalHeader()->height() * 6);
strokeTable->setMinimumWidth(strokeTable->sizeHint().width()); strokeTable->setMinimumWidth(strokeTable->sizeHint().width());
int row = 0; int row = 0;
// ÄÚÈÝ // ÄÚÈÝ
@ -131,7 +126,7 @@ void StrokeStyleWidget::initTable(const std::shared_ptr<Renderer::StrokeRadialGr
void StrokeStyleWidget::initAddButton() void StrokeStyleWidget::initAddButton()
{ {
this->addButton = new QtMaterialRaisedButton("+", strokeTable); this->addButton = new QtMaterialRaisedButton("+", strokeTable);
addButton->setFixedHeight(this->strokeTable->rowHeight(0)); addButton->setFixedHeight(30);
addButton->setBackgroundColor(ColorHelper::instance().getPrimary1()); addButton->setBackgroundColor(ColorHelper::instance().getPrimary1());
connect(addButton, &QtMaterialRaisedButton::clicked, [this] { connect(addButton, &QtMaterialRaisedButton::clicked, [this] {
handlingRowInsert = true; handlingRowInsert = true;

View File

@ -19,8 +19,8 @@ using Renderer::MaterialStyleFill;
QString getDisplayName() const override { return QStringLiteral(display_name); } \ QString getDisplayName() const override { return QStringLiteral(display_name); } \
static QString typeName() { return type_name; } \ static QString typeName() { return type_name; } \
QString getTypeName() const override { return type_name; } QString getTypeName() const override { return type_name; }
#define radialStroke(stroke) std::static_pointer_cast<Renderer::StrokeRadialGradient>(stroke->materialStroke) #define radialStroke(stroke) std::static_pointer_cast<Renderer::StrokeRadialGradient>((stroke)->materialStroke)
#define plainFill(fill) std::static_pointer_cast<Renderer::FillPlain>(fill->materialFill) #define plainFill(fill) std::static_pointer_cast<Renderer::FillPlain>((fill)->materialFill)
class LayerStyle : public Renderer::ElementStyle class LayerStyle : public Renderer::ElementStyle
{ {

View File

@ -15,8 +15,6 @@ using std::make_shared;
using std::min; using std::min;
using std::queue; using std::queue;
const double PaintingUtil::pi = acos(-1);
struct LayerNode { struct LayerNode {
LayerWrapper* nowLayer; LayerWrapper* nowLayer;
QTransform transfrom; QTransform transfrom;
@ -110,8 +108,9 @@ FolderLayerWrapper* PaintingUtil::handleLayerWrapper(LayerWrapper* nowLayer, QTr
qDebug() << material->halfWidth; qDebug() << material->halfWidth;
} }
QPainterPathStroker stroker; QPainterPathStroker stroker;
stroker.setWidth(lineWidth); stroker.setWidth(lineWidth * 2);
stroker.setCapStyle(Qt::RoundCap); stroker.setCapStyle(Qt::RoundCap);
stroker.setJoinStyle(Qt::RoundJoin);
QPainterPath strokePath = stroker.createStroke(painterPath); QPainterPath strokePath = stroker.createStroke(painterPath);
auto rect = transform.map(strokePath).boundingRect(); auto rect = transform.map(strokePath).boundingRect();
elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height()); elementTransform.bound = glm::vec4(rect.x(), rect.y(), rect.x() + rect.width(), rect.y() + rect.height());

View File

@ -5,7 +5,7 @@
class PaintingUtil class PaintingUtil
{ {
private: private:
static const double pi; //static const double pi;
static QJsonObject readJsonFile(QString jsonFilePath); static QJsonObject readJsonFile(QString jsonFilePath);
static FolderLayerWrapper* handleLayerWrapper(LayerWrapper* nowLayer, QTransform& transform, Renderer::Painting& painting); static FolderLayerWrapper* handleLayerWrapper(LayerWrapper* nowLayer, QTransform& transform, Renderer::Painting& painting);
//static double getMaxLineWidth(LayerWrapper* root); //static double getMaxLineWidth(LayerWrapper* root);

12
svg/4_L0-fill.svg Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<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"
viewBox="0 0 1735.4 1712.3" style="enable-background:new 0 0 1735.4 1712.3;" xml:space="preserve">
<style type="text/css">
.st0{stroke:#000000;stroke-miterlimit:10;}
</style>
<polygon class="st0" points="932.3,945.5 1007,887.6 1034.9,922.2 512.7,1320.5 488.7,1287.4 592.2,1208.1 546.2,1145.1
579.5,1120.1 627.3,1181.8 747.8,1088.8 278.2,440.8 158.8,520.8 199.7,578.8 163.3,604.9 120.1,546.9 28,608.3 0.7,569.7
497.7,234.2 526.1,272.9 463.5,316.1 507.9,379.8 477.2,402.5 430.6,337.7 303.9,424.4 778.3,1064.7 892.1,977.2 826.2,888
865.7,857.4 "/>
</svg>

After

Width:  |  Height:  |  Size: 822 B

View File

@ -59,9 +59,9 @@
"name": "Leaf2", "name": "Leaf2",
"styles": [ "styles": [
{ {
"enableEachSideIndependent": true, "enableEachSideIndependent": false,
"left": "AAAAQAEAIZwAf////1UA/w==", "left": "AAAAQAEAIZwAf////1UA/w==",
"right": "AADgQAAACJw=", "right": "AADgQAEACJwAf///AFqe/w==",
"type": "stroke" "type": "stroke"
} }
], ],