使宽度平滑过渡,并更新了对应的测试用例TestGradientWidth
parent
a0d45085dd
commit
3090f24235
|
@ -917,6 +917,7 @@ float getLocalWidth(float t, vec2 lengthRate, float originWidth, uint widthMapSi
|
||||||
if (currentLengthRate <= level)
|
if (currentLengthRate <= level)
|
||||||
{
|
{
|
||||||
float a = (currentLengthRate - lastLevel) / (level - lastLevel);
|
float a = (currentLengthRate - lastLevel) / (level - lastLevel);
|
||||||
|
a = smoothstep(0,1,a);
|
||||||
width = mix(lastWidth, currentWidth, a);
|
width = mix(lastWidth, currentWidth, a);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -253,27 +253,27 @@ namespace UnitTest
|
||||||
w.show();
|
w.show();
|
||||||
a.exec();
|
a.exec();
|
||||||
}
|
}
|
||||||
TEST_METHOD(TestBothSidesGradientWidth)
|
TEST_METHOD(TestGradientWidth)
|
||||||
{
|
{
|
||||||
/*QPainterPath testPath;
|
/*QPainterPath testPath;
|
||||||
testPath.moveTo(50, 50);
|
testPath.moveTo(50, 50);
|
||||||
testPath.cubicTo(50, 200, 200, 300, 300, 300);*/
|
testPath.cubicTo(50, 200, 200, 300, 300, 300);*/
|
||||||
QPainterPath testPath;
|
QPainterPath testPath;
|
||||||
SvgFileLoader().loadSvgFile("../../svg/3.svg", testPath);
|
SvgFileLoader().loadSvgFile("../../svg/3_2.svg", testPath);
|
||||||
testPath = QTransform::fromScale(10, 10).map(testPath);
|
testPath = QTransform::fromScale(3, 3).map(testPath);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
class StyleStrokeRadialGradient : public Renderer::ElementStyle
|
||||||
{
|
{
|
||||||
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override
|
||||||
{
|
{
|
||||||
std::map<float, Material> materialMap = {
|
std::map<float, Material> materialMap = {
|
||||||
{0.20, Material{QColor(255,255,255)}},
|
{0.40, Material{QColor(58,64,151)}},
|
||||||
{0.60, Material{QColor(165,176,207)}},
|
{0.80, Material{QColor(165,176,207)}},
|
||||||
{1.00, Material{QColor(58,64,151)}}
|
{1.00, Material{QColor(255,255,255)}}
|
||||||
};
|
};
|
||||||
return { BaseStyle(std::make_shared<TransformStyle>(),
|
return { BaseStyle(std::make_shared<TransformStyle>(),
|
||||||
std::make_shared<MaterialStyleStroke>(90, StrokeType::kRightSide, StrokeEndType::kFlatRound,
|
std::make_shared<MaterialStyleStroke>(80, StrokeType::kLeftSide, StrokeEndType::kFlatRound,
|
||||||
std::make_shared<StrokeRadialGradient>(materialMap, false), std::map<float, float>{ {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<StrokeRadialGradient>(materialMap, false), std::map<float, float>{ {0,1}, {0.95, 0.8},{1,0}})) };
|
||||||
}
|
}
|
||||||
} style;
|
} style;
|
||||||
TestGLWidget w(style, testPath);
|
TestGLWidget w(style, testPath);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 38.66 57"><defs><style>.cls-1{fill:none;stroke:#fff;stroke-miterlimit:10;}</style></defs><g id="图层_2" data-name="图层 2"><g id="图层_1-2" data-name="图层 1"><path class="cls-1" d="M.81,0C.12,12.47.64,23.24,1.87,29.9c1.85,10,3.32,18,10.21,22.72,5.59,3.83,15.45,6,21.45.77,2.53-2.22,4.92-5.91,4.6-10a9.27,9.27,0,0,0-2-5.55,1.84,1.84,0,0,0-2.16-.51c-.67.36-1.39,1.08-1.11,1.79s1.81,1,2.85.59"/></g></g></svg>
|
After Width: | Height: | Size: 468 B |
Loading…
Reference in New Issue