bool longSegment = false;
int numPoints = (int)ceil(points) * 2.0;
float angleDir = ((dir == VPath::Direction::CW) ? 1.0 : -1.0);
+ bool hasRoundness = false;
innerRoundness /= 100.0;
outerRoundness /= 100.0;
currentAngle += halfAnglePerPoint * angleDir;
}
+ if (vIsZero(innerRoundness) && vIsZero(outerRoundness)) {
+ reserve(numPoints + 2, numPoints + 3);
+ } else {
+ reserve(numPoints * 3 + 2, numPoints + 3);
+ hasRoundness = true;
+ }
+
moveTo(VPointF(x + cx, y + cy));
for (int i = 0; i < numPoints; i++) {
x = (float)(radius * cos(currentAngle));
y = (float)(radius * sin(currentAngle));
- if (innerRoundness == 0 && outerRoundness == 0) {
- lineTo(VPointF(x + cx, y + cy));
- } else {
+ if (hasRoundness) {
float cp1Theta =
(float)(atan2(previousY, previousX) - M_PI / 2.0 * angleDir);
float cp1Dx = (float)cos(cp1Theta);
cubicTo(VPointF(previousX - cp1x + cx, previousY - cp1y + cy),
VPointF(x + cp2x + cx, y + cp2y + cy),
VPointF(x + cx, y + cy));
+ } else {
+ lineTo(VPointF(x + cx, y + cy));
}
currentAngle += dTheta * angleDir;
float anglePerPoint = (float)(2.0 * M_PI / floor(points));
int numPoints = (int)floor(points);
float angleDir = ((dir == VPath::Direction::CW) ? 1.0 : -1.0);
+ bool hasRoundness = false;
roundness /= 100.0;
y = (float)(radius * sin(currentAngle));
currentAngle += anglePerPoint * angleDir;
+ if (vIsZero(roundness)) {
+ reserve(numPoints + 2, numPoints + 3);
+ } else {
+ reserve(numPoints * 3 + 2, numPoints + 3);
+ hasRoundness = true;
+ }
+
moveTo(VPointF(x + cx, y + cy));
for (int i = 0; i < numPoints; i++) {
x = (float)(radius * cos(currentAngle));
y = (float)(radius * sin(currentAngle));
- if (roundness != 0) {
+ if (hasRoundness) {
float cp1Theta =
(float)(atan2(previousY, previousX) - M_PI / 2.0 * angleDir);
float cp1Dx = (float)cos(cp1Theta);