FIX: GraphicElement中pixelRatio计算错误

dev-LayerStyle
wuyize 2023-03-17 12:29:31 +08:00
parent 2569b07233
commit 6a09bdd32c
1 changed files with 11 additions and 8 deletions

View File

@ -102,12 +102,15 @@ void SimpleElement::paint(QPainter* painter, QTransform transform, const vector<
} }
else else
{ {
Renderer::ElementStyleStrokeDemo demo(2);
std::shared_ptr<Renderer::ElementStyle> style; std::shared_ptr<Renderer::ElementStyle> style;
style = styles[0]; style = styles[0];
QVector2D scale(transform.m11(), transform.m22());
scale /= transform.m33(); double angle = atan(transform.m12() / transform.m11());
double maxScale = std::max(scale.x(), scale.y()); double maxScale;
if (fabs(cos(angle))>1e-5)
maxScale = std::max(fabs(transform.m11() / cos(angle)), fabs(transform.m22() / cos(angle)));
else
maxScale = std::max(fabs(transform.m12() / sin(angle)), fabs(transform.m21() / sin(angle)));
double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio(); double pixelRatio = maxScale * QGuiApplication::primaryScreen()->devicePixelRatio();
auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, *style, pixelRatio); auto [img, mov] = Renderer::ElementRenderer::instance()->drawElement(painterPath, *style, pixelRatio);
transform.translate(mov.x(), mov.y()); transform.translate(mov.x(), mov.y());