修改旋转判定,添加style渲染接口

dev-LayerStyle
karlis 2023-03-14 15:36:19 +08:00
parent f2ceca724a
commit 97097fcc3a
2 changed files with 14 additions and 5 deletions

View File

@ -87,11 +87,20 @@ QJsonObject GraphicElement::toJson() const
void SimpleElement::paint(QPainter* painter, QTransform transform, vector<std::shared_ptr<LayerStyle>> styles)
{
Renderer::ElementStyleStrokeDemo demo(2);
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
painter->save();
painter->setTransform(transform);
painter->drawImage(mov, img);
if (styles.empty())
{
painter->drawPath(painterPath);
}
else
{
// TODO:Ó¦ÓÃstyle
Renderer::ElementStyleStrokeDemo demo(2);
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
painter->drawImage(mov, img);
}
painter->restore();
}

View File

@ -88,9 +88,9 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
currentLayer->property.offset.setY(currentLayer->property.offset.y() + dy);
qDebug() << dx << "----" << dy;
}
else if (event->buttons() & Qt::RightButton) {
else if (event->buttons() & Qt::RightButton) {
// 如果按下的是右键,那么旋转图形
qreal angle = -sqrt(dx * dx + dy * dy) / 1.0;
qreal angle = dx;
currentLayer->property.rotation += angle;
}
}