float innerRoundness, float outerRoundness,
VPath::Direction dir)
{
- // TODO: Direction feature is missing
const static float POLYSTAR_MAGIC_NUMBER = 0.47829 / 0.28;
float currentAngle = (startAngle - 90.0) * M_PI / 180.0;
float x;
float partialPointAmount = points - (int) points;
bool longSegment = false;
int numPoints = (int) ceil(points) * 2.0;
+ float angleDir = ((dir == VPath::Direction::CW) ? 1.0 : -1.0);
innerRoundness /= 100.0;
outerRoundness /= 100.0;
if (partialPointAmount != 0) {
- currentAngle += halfAnglePerPoint * (1.0 - partialPointAmount);
+ currentAngle += halfAnglePerPoint * (1.0 - partialPointAmount) * angleDir;
}
if (partialPointAmount != 0) {
partialPointRadius = innerRadius + partialPointAmount * (outerRadius - innerRadius);
x = (float) (partialPointRadius * cos(currentAngle));
y = (float) (partialPointRadius * sin(currentAngle));
- currentAngle += anglePerPoint * partialPointAmount / 2.0;
+ currentAngle += anglePerPoint * partialPointAmount / 2.0 * angleDir;
} else {
x = (float) (outerRadius * cos(currentAngle));
y = (float) (outerRadius * sin(currentAngle));
- currentAngle += halfAnglePerPoint;
+ currentAngle += halfAnglePerPoint * angleDir;
}
moveTo(VPointF(x + cx, y + cy));
if (innerRoundness == 0 && outerRoundness == 0) {
lineTo(VPointF(x + cx, y + cy));
} else {
- float cp1Theta = (float) (atan2(previousY, previousX) - M_PI / 2.0);
+ float cp1Theta = (float) (atan2(previousY, previousX) - M_PI / 2.0 * angleDir);
float cp1Dx = (float) cos(cp1Theta);
float cp1Dy = (float) sin(cp1Theta);
-
- float cp2Theta = (float) (atan2(y, x) - M_PI / 2.0);
+ float cp2Theta = (float) (atan2(y, x) - M_PI / 2.0 * angleDir);
float cp2Dx = (float) cos(cp2Theta);
float cp2Dy = (float) sin(cp2Theta);
VPointF(x + cx, y + cy));
}
- currentAngle += dTheta;
+ currentAngle += dTheta * angleDir;
longSegment = !longSegment;
}
float radius, float roundness,
VPath::Direction dir)
{
- // TODO: Direction feature is missing
// TODO: Need to support floating point number for number of points
const static float POLYGON_MAGIC_NUMBER = 0.25;
float currentAngle = (startAngle - 90.0) * M_PI / 180.0;
float previousY;
float anglePerPoint = (float) (2.0 * M_PI / floor(points));
int numPoints = (int) floor(points);
+ float angleDir = ((dir == VPath::Direction::CW) ? 1.0 : -1.0);
roundness /= 100.0;
currentAngle = (currentAngle - 90.0) * M_PI / 180.0;
x = (float) (radius * cos(currentAngle));
y = (float) (radius * sin(currentAngle));
- currentAngle += anglePerPoint;
+ currentAngle += anglePerPoint * angleDir;
moveTo(VPointF(x + cx, y + cy));
y = (float) (radius * sin(currentAngle));
if (roundness != 0) {
- float cp1Theta = (float) (atan2(previousY, previousX) - M_PI / 2.0);
+ float cp1Theta = (float) (atan2(previousY, previousX) - M_PI / 2.0 * angleDir);
float cp1Dx = (float) cos(cp1Theta);
float cp1Dy = (float) sin(cp1Theta);
-
- float cp2Theta = (float) (atan2(y, x) - M_PI / 2.0);
+ float cp2Theta = (float) (atan2(y, x) - M_PI / 2.0 * angleDir);
float cp2Dx = (float) cos(cp2Theta);
float cp2Dy = (float) sin(cp2Theta);
lineTo(VPointF(x + cx, y + cy));
}
- currentAngle += anglePerPoint;
+ currentAngle += anglePerPoint * angleDir;
}
close();