-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgradientcolor.cpp
23 lines (19 loc) · 950 Bytes
/
gradientcolor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "gradientcolor.h"
gradientColor::gradientColor(int startWeight, int endWeight, int activeLayers, int colorExtruder)
{
gradientColor::startWeight = startWeight;
gradientColor::endWeight = endWeight;
gradientColor::activeLayers = activeLayers;
gradientColor::colorExtruder = colorExtruder;
(startWeight > endWeight) ? gradientColor::ascending = -1 : gradientColor::ascending = 1;
int activeWeights = abs(endWeight - startWeight);
gradientColor::weightDelta = (float)activeWeights/(float)activeLayers;
gradientColor::nextActiveWeight = startWeight;
gradientColor::floatNextActiveWeight = startWeight;
}
QString gradientColor::printAndIncrement(){
QString toReturn = QString("M163 S%1 P%2\n").arg(QString::number(colorExtruder),QString::number(nextActiveWeight));
floatNextActiveWeight += weightDelta*ascending;
nextActiveWeight = qRound(floatNextActiveWeight);
return toReturn;
}