GraphicElement改为使用QImage

dev-VirtualTexture
wuyize 2023-02-08 18:33:26 +08:00
parent 16bfba76e4
commit e004809164
3 changed files with 29 additions and 31 deletions

View File

@ -1033,8 +1033,9 @@ void main()
if (lineType == 2 || intTest % 2 == int(lineType)) if (lineType == 2 || intTest % 2 == int(lineType))
{ {
hitElement = true; hitElement = true;
elementColor = vec4(1, 1, 0, 1); //elementColor = vec4(1, 1, 0, 1);
// drawLine(minDistance / strokeWidth, styleIndex, elementColor, metallicRoughness); vec2 metallicRoughness;
drawLine(minDistance / strokeWidth, styleIndex, elementColor, metallicRoughness);
} }
else if (p3Last == p[0]) else if (p3Last == p[0])
hitElement = false; hitElement = false;

View File

@ -6,62 +6,62 @@ PixelPath SimpleElement::getPaintObject() const
{ {
PixelPath result; PixelPath result;
result.addPath(painterPath); result.addPath(painterPath);
return result; return result;
} }
void SimpleElement::loadSvgFile(const QString& filePath) void SimpleElement::loadSvgFile(const QString& filePath)
{ {
// TODO ÑùʽÎÊÌâ // TODO ÑùʽÎÊÌâ
SvgFileLoader loader; SvgFileLoader loader;
loader.loadSvgFile(filePath, painterPath); loader.loadSvgFile(filePath, painterPath);
qDebug() << "load svg file success "<<painterPath.elementCount(); qDebug() << "load svg file success " << painterPath.elementCount();
} }
SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource) SimpleElement::SimpleElement(QJsonObject jsonSource) : jsonSource(jsonSource)
{ {
painterPath.clear(); painterPath.clear();
//loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg"); //loadSvgFile("D:\\Projects\\BigC\\svg\\3.svg");
loadSvgFile("../"/*TODO: 改成json文件所在文件夹路径*/ + jsonSource.value("data").toObject().value("include").toString()); loadSvgFile("../"/*TODO: 改成json文件所在文件夹路径*/ + jsonSource.value("data").toObject().value("include").toString());
} }
GroupElement::GroupElement(FolderLayerWrapper *sourceLayer) GroupElement::GroupElement(FolderLayerWrapper* sourceLayer)
{ {
this->sourceLayer = sourceLayer; this->sourceLayer = sourceLayer;
} }
void GroupElement::setSourceLayer(FolderLayerWrapper *sourceLayer) void GroupElement::setSourceLayer(FolderLayerWrapper* sourceLayer)
{ {
this->sourceLayer = sourceLayer; this->sourceLayer = sourceLayer;
} }
PixelPath GroupElement::getPaintObject() const PixelPath GroupElement::getPaintObject() const
{ {
if (sourceLayer != nullptr) { if (sourceLayer != nullptr) {
sourceLayer->refresh(); sourceLayer->refresh();
return sourceLayer->getCache(); return sourceLayer->getCache();
} }
else else
return PixelPath(); return PixelPath();
} }
//TODO: apply styles and send back //TODO: apply styles and send back
PixelPath SimpleElement::getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo> styles) const { PixelPath SimpleElement::getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo> styles) const {
PixelPath result; PixelPath result;
Renderer::ElementStyleStrokeDemo demo; Renderer::ElementStyleStrokeDemo demo(2);
qDebug() << (renderer==nullptr)<<"------------"; qDebug() << (renderer == nullptr) << "------------";
//auto [img, mov] = renderer->drawElement(painterPath,demo,1.0,false); auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0, false);
//qDebug() << img << " ------"; //qDebug() << img << " ------";
//result.addImage(img, mov); result.addImage(img, mov);
result.addPath(painterPath); //result.addPath(painterPath);
// QImage img(80,80,QImage::Format_ARGB32); // QImage img(80,80,QImage::Format_ARGB32);
// QPainter pt(&img); // QPainter pt(&img);
//pt.setPen(QPen(Qt::red, 2)); //pt.setPen(QPen(Qt::red, 2));
//pt.drawLine(0, 0, 80, 80); //pt.drawLine(0, 0, 80, 80);
//pt.end(); //pt.end();
//result.addImage(img, QPoint(0, 0)); //result.addImage(img, QPoint(0, 0));
return result; return result;
} }
PixelPath GroupElement::getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo> styles) const { PixelPath GroupElement::getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo> styles) const {
return getPaintObject(); return getPaintObject();
} }
//BitmapPath::BitmapPath() { //BitmapPath::BitmapPath() {

View File

@ -1,11 +1,8 @@
#include "MainWindow.h" #include "MainWindow.h"
#include "Renderer/Painting/CubicBezier.h"
#include <QGuiApplication> #include <QGuiApplication>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <FramelessHelper/Core/private/framelessconfig_p.h> #include <FramelessHelper/Core/private/framelessconfig_p.h>
using Renderer::CubicBezier;
extern "C" extern "C"
{ {
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; _declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
@ -20,7 +17,7 @@ int main(int argc, char* argv[])
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QApplication a(argc, argv); QApplication a(argc, argv);
FramelessHelper::Core::setApplicationOSThemeAware(); //FramelessHelper::Core::setApplicationOSThemeAware();
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);