diff --git a/ArchitectureColoredPainting/res/Shaders/element.comp b/ArchitectureColoredPainting/res/Shaders/element.comp index e215250..eb74677 100644 --- a/ArchitectureColoredPainting/res/Shaders/element.comp +++ b/ArchitectureColoredPainting/res/Shaders/element.comp @@ -917,6 +917,7 @@ float getLocalWidth(float t, vec2 lengthRate, float originWidth, uint widthMapSi if (currentLengthRate <= level) { float a = (currentLengthRate - lastLevel) / (level - lastLevel); + a = smoothstep(0,1,a); width = mix(lastWidth, currentWidth, a); found = true; break; diff --git a/UnitTest/ElementRendererTest.cpp b/UnitTest/ElementRendererTest.cpp index 5356603..981c0b0 100644 --- a/UnitTest/ElementRendererTest.cpp +++ b/UnitTest/ElementRendererTest.cpp @@ -253,27 +253,27 @@ namespace UnitTest w.show(); a.exec(); } - TEST_METHOD(TestBothSidesGradientWidth) + TEST_METHOD(TestGradientWidth) { /*QPainterPath testPath; testPath.moveTo(50, 50); testPath.cubicTo(50, 200, 200, 300, 300, 300);*/ QPainterPath testPath; - SvgFileLoader().loadSvgFile("../../svg/3.svg", testPath); - testPath = QTransform::fromScale(10, 10).map(testPath); + SvgFileLoader().loadSvgFile("../../svg/3_2.svg", testPath); + testPath = QTransform::fromScale(3, 3).map(testPath); QApplication a(argc, argv); class StyleStrokeRadialGradient : public Renderer::ElementStyle { virtual std::vector toBaseStyles() const override { std::map materialMap = { - {0.20, Material{QColor(255,255,255)}}, - {0.60, Material{QColor(165,176,207)}}, - {1.00, Material{QColor(58,64,151)}} + {0.40, Material{QColor(58,64,151)}}, + {0.80, Material{QColor(165,176,207)}}, + {1.00, Material{QColor(255,255,255)}} }; return { BaseStyle(std::make_shared(), - std::make_shared(90, StrokeType::kRightSide, StrokeEndType::kFlatRound, - std::make_shared(materialMap, false), std::map{ {0.6,1},{0.8, 0.8},{0.94,0.6}, {0.96,0.6},{0.97,0.4},{1,0.1}})) }; + std::make_shared(80, StrokeType::kLeftSide, StrokeEndType::kFlatRound, + std::make_shared(materialMap, false), std::map{ {0,1}, {0.95, 0.8},{1,0}})) }; } } style; TestGLWidget w(style, testPath); diff --git a/svg/3_2.svg b/svg/3_2.svg new file mode 100644 index 0000000..e74b429 --- /dev/null +++ b/svg/3_2.svg @@ -0,0 +1 @@ + \ No newline at end of file