Fix: 画布改变后显示错误

main
wuyize 2023-03-29 15:04:17 +08:00
parent 38336aa944
commit ae77ffdbdb
4 changed files with 11 additions and 8 deletions

View File

@ -72,7 +72,7 @@ void PreviewWindow::paintGL()
glClearColor(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF(), backgroundColor.alphaF()); glClearColor(backgroundColor.redF(), backgroundColor.greenF(), backgroundColor.blueF(), backgroundColor.alphaF());
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
painter->begin(this); painter->begin(this);
painter->setWindow(0, 0, actualSize.width() * devicePixelRatioF(), actualSize.height() * devicePixelRatioF()); painter->setWindow(0, 0, referSize.width() * devicePixelRatioF(), referSize.height() * devicePixelRatioF());
painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::Antialiasing);
painter->setRenderHint(QPainter::HighQualityAntialiasing); painter->setRenderHint(QPainter::HighQualityAntialiasing);
layerManager->paint(painter, this->size(), currentLayer); layerManager->paint(painter, this->size(), currentLayer);

View File

@ -66,14 +66,16 @@ std::unique_ptr<MaterialStyle> Renderer::MaterialStyle::decoded(const std::vecto
std::unique_ptr<MaterialStroke> materialStroke; std::unique_ptr<MaterialStroke> materialStroke;
std::map<float, float> widthMap; std::map<float, float> widthMap;
uint widthMapSize = floatBitsToUint(encoded[1]); uint widthMapSize = floatBitsToUint(encoded[1]);
for (int i = 0; i < widthMapSize; i++)
{
glm::vec2 v = glm::unpackUnorm2x16(glm::floatBitsToUint(encoded[2 + i]));
widthMap.emplace(v.x, v.y);
}
uint headIndex = widthMapSize + 2; uint headIndex = widthMapSize + 2;
if (encoded[1] < 0) if (encoded[1] < 0)
headIndex = 1; /// 쇗휭앉경긍쯤 headIndex = 1; /// 쇗휭앉경긍쯤
else
for (int i = 0; i < widthMapSize; i++)
{
glm::vec2 v = glm::unpackUnorm2x16(glm::floatBitsToUint(encoded[2 + i]));
widthMap.emplace(v.x, v.y);
}
uint headUint = floatBitsToUint(encoded[headIndex]); uint headUint = floatBitsToUint(encoded[headIndex]);
vec4 head = unpackUnorm4x8(headUint); vec4 head = unpackUnorm4x8(headUint);
StrokeType strokeType = (StrokeType)floor(head.b * 10); StrokeType strokeType = (StrokeType)floor(head.b * 10);

View File

@ -83,7 +83,7 @@ std::vector<glm::vec2> generatePathBuffer(const QPainterPath& path)
pathBuffer.push_back(end); pathBuffer.push_back(end);
pathBuffer.emplace_back(lengths[j][k] / lengths[j].back(), lengths[j][k+1] / lengths[j].back()); pathBuffer.emplace_back(lengths[j][k] / lengths[j].back(), lengths[j][k+1] / lengths[j].back());
k++; k++;
qDebug() << pathBuffer.back().x << pathBuffer.back().y; //qDebug() << pathBuffer.back().x << pathBuffer.back().y;
lastPoint = end; lastPoint = end;
break; break;
} }
@ -105,7 +105,7 @@ std::vector<glm::vec2> generatePathBuffer(const QPainterPath& path)
pathBuffer.push_back(p3); pathBuffer.push_back(p3);
pathBuffer.emplace_back(lengths[j][k] / lengths[j].back(), lengths[j][k+1] / lengths[j].back()); pathBuffer.emplace_back(lengths[j][k] / lengths[j].back(), lengths[j][k+1] / lengths[j].back());
k++; k++;
qDebug() << pathBuffer.back().x << pathBuffer.back().y; //qDebug() << pathBuffer.back().x << pathBuffer.back().y;
lastPoint = p3; lastPoint = p3;
} }
break; break;

1
svg/T.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50.52 15.81"><defs><style>.cls-1{fill:#fff;stroke:#231815;stroke-miterlimit:10;}</style></defs><g id="图层_2" data-name="图层 2"><g id="图层_1-2" data-name="图层 1"><polygon class="cls-1" points="0.5 0.5 50.02 0.5 50.02 4.2 27.23 4.2 27.23 15.31 23.29 15.31 23.29 4.2 0.5 4.2 0.5 0.5"/></g></g></svg>

After

Width:  |  Height:  |  Size: 361 B