Fix: StrokeEndType::kClosed渲染不正确
parent
e39eb15f03
commit
a84c8cb752
|
@ -24,7 +24,7 @@
|
|||
},
|
||||
{
|
||||
"data": {
|
||||
"include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/4_L0-fill.svg"
|
||||
"include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/4_L0.svg"
|
||||
},
|
||||
"name": "4_L0-fill.svg",
|
||||
"type": "svg-file"
|
||||
|
|
|
@ -225,9 +225,6 @@
|
|||
<ClCompile Include="src\NavigationBarWidget.cpp">
|
||||
<Filter>Source Files\Editor</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
||||
<Filter>Source Files\Editor</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\EditorWidget.cpp">
|
||||
<Filter>Source Files\Editor</Filter>
|
||||
</ClCompile>
|
||||
|
@ -264,6 +261,9 @@
|
|||
<ClCompile Include="src\Editor\DataManager\ProjectDataManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
||||
<Filter>Source Files\Editor</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||
|
|
|
@ -1132,12 +1132,6 @@ void main()
|
|||
vec2 pTemp = path[pathIndex + 1];
|
||||
if (isinf(pTemp.x))
|
||||
{
|
||||
if(endType == 4)
|
||||
{
|
||||
//onVeryEnd = false;
|
||||
tangentBeginNext = tangentFirstBegin;
|
||||
}
|
||||
else
|
||||
onVeryEnd = true;
|
||||
}
|
||||
else
|
||||
|
@ -1150,8 +1144,17 @@ void main()
|
|||
tangentBeginNext = normalize(pNext[0] - pNext[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(endType == 4)
|
||||
{
|
||||
//onVeryEnd = false;
|
||||
tangentBeginNext = tangentFirstBegin;
|
||||
}
|
||||
else
|
||||
onVeryEnd = true;
|
||||
}
|
||||
|
||||
|
||||
float d = cubic_bezier_dis(localUV, p[0], p[1], p[2], p[3], true);
|
||||
if (d <= strokeWidth)
|
||||
|
@ -1199,7 +1202,7 @@ void main()
|
|||
}
|
||||
}
|
||||
tangentEndLast = tangentEnd;
|
||||
if(pathIndex == 0)
|
||||
if(pathIndex == 4)
|
||||
tangentFirstBegin = tangentBegin;
|
||||
}
|
||||
p3Last = p[3];
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "ElementRendererTest.h"
|
||||
#include "Renderer/Painting/ElementStyle.h"
|
||||
#include "Renderer/Painting/MaterialStyleFill.h"
|
||||
#include "Editor/util/SvgFileLoader.h"
|
||||
|
||||
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
|
||||
using namespace Renderer;
|
||||
|
@ -203,6 +204,30 @@ namespace UnitTest
|
|||
w.show();
|
||||
a.exec();
|
||||
}
|
||||
TEST_METHOD(TestBothSidesClosed)
|
||||
{
|
||||
QPainterPath closedPath;
|
||||
SvgFileLoader().loadSvgFile("../../svg/4_L0.svg", closedPath);
|
||||
closedPath = QTransform::fromScale(5, 5).map(closedPath);
|
||||
QApplication a(argc, argv);
|
||||
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
||||
{
|
||||
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
||||
{
|
||||
std::map<float, Material> materialMap = {
|
||||
{0.20, Material{QColor(255,255,255)}},
|
||||
{0.60, Material{QColor(165,176,207)}},
|
||||
{1.00, Material{QColor(58,64,151)}}
|
||||
};
|
||||
return { BaseStyle(std::make_shared<TransformStyle>(),
|
||||
std::make_shared<MaterialStyleStroke>(20, StrokeType::kLeftSide, StrokeEndType::kClosed,
|
||||
std::make_shared<StrokeRadialGradient>(materialMap, false))) };
|
||||
}
|
||||
} style;
|
||||
TestGLWidget w(style, closedPath);
|
||||
w.show();
|
||||
a.exec();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CLASS(ElementRendererStokeMaterialTest)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<svg id="万字笔画" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1068 1045">
|
||||
<title>4_L0</title>
|
||||
<polyline points="873 0 360 390 427 483 490 439 600 592 690 524 750 608 189 1045" fill="none"/>
|
||||
<polyline points="1068 830 651 303 566 373 629 455 487 566 538 632 461 696 0 99" fill="none"/>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 141 171">
|
||||
<title>4_L0的副本</title>
|
||||
<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"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 307 B After Width: | Height: | Size: 480 B |
31
test.json
31
test.json
|
@ -21,6 +21,13 @@
|
|||
},
|
||||
"name": "ababa2",
|
||||
"type": "svg-file"
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"include": "D:/BigC2022/temp/ArchitectureColoredPainting/svg/3.svg"
|
||||
},
|
||||
"name": "3.svg",
|
||||
"type": "svg-file"
|
||||
}
|
||||
],
|
||||
"height": 1080,
|
||||
|
@ -76,6 +83,30 @@
|
|||
"y": 1.5
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"element": -842150451,
|
||||
"is-folder": false,
|
||||
"name": "子图层-3",
|
||||
"styles": [
|
||||
{
|
||||
"enableEachSideIndependent": false,
|
||||
"left": "AAAAQAEAIZwAf///AP8A/w==",
|
||||
"right": "AADgQAAACJw=",
|
||||
"type": "stroke"
|
||||
}
|
||||
],
|
||||
"transform": {
|
||||
"offset": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"rotation": 0,
|
||||
"scale": {
|
||||
"x": 1,
|
||||
"y": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"is-folder": true,
|
||||
|
|
Loading…
Reference in New Issue