Skip to content

Commit bcbe09b

Browse files
committed
Use QNanoColor for pen color
1 parent 76d88d9 commit bcbe09b

File tree

7 files changed

+90
-91
lines changed

7 files changed

+90
-91
lines changed

src/penattributes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
#pragma once
44

5-
#include <QColor>
5+
#include <qnanocolor.h>
66

77
namespace scratchcpprender
88
{
99

1010
struct PenAttributes
1111
{
12-
QColor color = QColor(0, 0, 255);
12+
QNanoColor color = QNanoColor(0, 0, 255);
1313
double diameter = 1;
1414
};
1515

src/penlayer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ void scratchcpprender::PenLayer::drawLine(const PenAttributes &penAttributes, do
109109

110110
// Set pen attributes
111111
m_painter->setLineWidth(penAttributes.diameter);
112-
QNanoColor col(penAttributes.color.red(), penAttributes.color.green(), penAttributes.color.blue(), penAttributes.color.alpha());
113-
m_painter->setStrokeStyle(col);
114-
m_painter->setFillStyle(col);
112+
m_painter->setStrokeStyle(penAttributes.color);
113+
m_painter->setFillStyle(penAttributes.color);
115114
m_painter->setLineJoin(QNanoPainter::JOIN_ROUND);
116115
m_painter->setLineCap(QNanoPainter::CAP_ROUND);
117116
m_painter->setAntialias(m_antialiasingEnabled ? 1.0f : 0.0f);

src/penstate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct PenState
3131
const int v = brightness * 255 / 100;
3232
const int a = 255 - transparency * 255 / 100;
3333

34-
penAttributes.color = QColor::fromHsv(h, s, v, a);
34+
penAttributes.color = QNanoColor::fromQColor(QColor::fromHsv(h, s, v, a));
3535
}
3636
};
3737

0 commit comments

Comments
 (0)