//FIXME; Scale + Rotation is not working properly
radius *= sx;
- if (abs(sx - sy) > FLT_EPSILON) {
+ if (fabsf(sx - sy) > FLT_EPSILON) {
fill->sx = sx;
fill->sy = sy;
}
float t = (fill->linear.dx * rx + fill->linear.dy * ry + fill->linear.offset) * (GRADIENT_STOP_SIZE - 1);
float inc = (fill->linear.dx) * (GRADIENT_STOP_SIZE - 1);
- if (abs(inc) < FLT_EPSILON) {
+ if (fabsf(inc) < FLT_EPSILON) {
auto color = _fixedPixel(fill, static_cast<int32_t>(t * FIXPT_SIZE));
rasterRGBA32(dst, color, 0, len);
return;
static inline void SCALE(const SwStroke& stroke, SwPoint& pt)
{
- pt.x *= stroke.sx;
- pt.y *= stroke.sy;
+ pt.x = static_cast<SwCoord>(pt.x * stroke.sx);
+ pt.y = static_cast<SwCoord>(pt.y * stroke.sy);
}
auto len = _lineLength(cur.start, cur.ctrl1) + _lineLength(cur.ctrl1, cur.ctrl2) + _lineLength(cur.ctrl2, cur.end);
auto chord = _lineLength(cur.start, cur.end);
- if (fabs(len - chord) > BEZIER_EPSILON) {
+ if (fabsf(len - chord) > BEZIER_EPSILON) {
bezSplit(cur, left, right);
return bezLength(left) + bezLength(right);
}
bezSplitLeft(right, t, left);
len = bezLength(left);
- if (fabs(len - at) < BEZIER_EPSILON || fabs(smallest - biggest) < BEZIER_EPSILON) {
+ if (fabsf(len - at) < BEZIER_EPSILON || fabsf(smallest - biggest) < BEZIER_EPSILON) {
break;
}
startAngle = (startAngle * M_PI) / 180;
sweep = sweep * M_PI / 180;
- auto nCurves = ceil(abs(sweep / M_PI_HALF));
+ auto nCurves = ceil(fabsf(sweep / M_PI_HALF));
auto sweepSign = (sweep < 0 ? -1 : 1);
auto fract = fmodf(sweep, M_PI_HALF);
fract = (fabsf(fract) < std::numeric_limits<float>::epsilon()) ? M_PI_HALF * sweepSign : fract;
auto by = end.y;
auto q1 = ax * ax + ay * ay;
auto q2 = ax * bx + ay * by + q1;
- auto k2 = static_cast<float> (4.0/3.0) * ((sqrtf(2 * q1 * q2) - q2) / (ax * by - ay * bx));
+ auto k2 = (4.0f/3.0f) * ((sqrtf(2 * q1 * q2) - q2) / (ax * by - ay * bx));
start = end; //Next start point is the current end point
//Correction of out-of-range radii, see F6.6.2 (step 4)
if (lambda > 1.0f) {
//See F6.6.3
- float lambdaRoot = sqrt(lambda);
+ float lambdaRoot = sqrtf(lambda);
rx *= lambdaRoot;
ry *= lambdaRoot;
if (c < 0.0f) {
//Scale uniformly until we have a single solution
//(see F6.2) i.e. when c == 0.0
- float scale = sqrt(1.0f - c / (rx2 * ry2));
+ float scale = sqrtf(1.0f - c / (rx2 * ry2));
rx *= scale;
ry *= scale;
//Update rx2 and ry2
cy = 0.0f;
} else {
//Complete c calculation
- c = sqrt(c / ((rx2 * y1p2) + (ry2 * x1p2)));
+ c = sqrtf(c / ((rx2 * y1p2) + (ry2 * x1p2)));
//Inverse sign if Fa == Fs
if (largeArc == sweep) c = -c;
//(smaller than 90 degrees)
//We add one extra segment because we want something
//Smaller than 90deg (i.e. not 90 itself)
- segments = (int)(fabsf(deltaTheta / float(M_PI_2))) + 1.0f;
+ segments = static_cast<int>(fabsf(deltaTheta / float(M_PI_2)) + 1.0f);
delta = deltaTheta / segments;
//http://www.stillhq.com/ctpfaq/2001/comp.text.pdf-faq-2001-04.txt (section 2.13)
- bcp = 4.0f / 3.0f * (1.0f - cos(delta / 2.0f)) / sin(delta / 2.0f);
+ bcp = 4.0f / 3.0f * (1.0f - cosf(delta / 2.0f)) / sinf(delta / 2.0f);
cosPhiRx = cosPhi * rx;
cosPhiRy = cosPhi * ry;
sinPhiRx = sinPhi * rx;
sinPhiRy = sinPhi * ry;
- cosTheta1 = cos(theta1);
- sinTheta1 = sin(theta1);
+ cosTheta1 = cosf(theta1);
+ sinTheta1 = sinf(theta1);
for (int i = 0; i < segments; ++i) {
//End angle (for this segment) = current + delta
float c1x, c1y, ex, ey, c2x, c2y;
float theta2 = theta1 + delta;
- float cosTheta2 = cos(theta2);
- float sinTheta2 = sin(theta2);
+ float cosTheta2 = cosf(theta2);
+ float sinTheta2 = sinf(theta2);
Point p[3];
//First control point (based on start point sx,sy)
stops[i].r = colorStop->r;
stops[i].g = colorStop->g;
stops[i].b = colorStop->b;
- stops[i].a = (colorStop->a * opacity) / 255.0f;
+ stops[i].a = static_cast<uint8_t>((colorStop->a * opacity) / 255);
stops[i].offset = colorStop->offset;
//check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes
if (colorStop->offset < prevOffset) stops[i].offset = prevOffset;
int radius;
auto fillGrad = RadialGradient::gen();
- radius = sqrt(pow(rw, 2) + pow(rh, 2)) / sqrt(2.0);
+ radius = static_cast<int>(sqrtf(pow(rw, 2) + pow(rh, 2)) / sqrtf(2.0));
if (!g->userSpace) {
//That is according to Units in here
//https://www.w3.org/TR/2015/WD-SVG2-20150915/coords.html
- int min = (rh > rw) ? rw : rh;
- radius = sqrt(pow(min, 2) + pow(min, 2)) / sqrt(2.0);
+ int min = static_cast<int>((rh > rw) ? rw : rh);
+ radius = static_cast<int>(sqrtf(pow(min, 2) + pow(min, 2)) / sqrtf(2.0));
}
if (g->usePercentage) {
g->radial->cy = g->radial->cx * g->transform->e21 + g->radial->cy * g->transform->e22 + g->transform->e23;
g->radial->cx = cx;
- auto sx = sqrt(pow(g->transform->e11, 2) + pow(g->transform->e21, 2));
+ auto sx = sqrtf(pow(g->transform->e11, 2) + pow(g->transform->e21, 2));
g->radial->r *= sx;
}
stops[i].r = colorStop->r;
stops[i].g = colorStop->g;
stops[i].b = colorStop->b;
- stops[i].a = (colorStop->a * opacity) / 255.0f;
+ stops[i].a = static_cast<uint8_t>((colorStop->a * opacity) / 255);
stops[i].offset = colorStop->offset;
//check the offset corner cases - refer to: https://svgwg.org/svg2-draft/pservers.html#StopNotes
if (colorStop->offset < prevOffset) stops[i].offset = prevOffset;
//width
auto width = shape->strokeWidth();
- if (preTransform) width *= sqrt(pow(pTransform->e11, 2) + pow(pTransform->e21, 2)); //we know x/y scaling factors are same.
+ if (preTransform) width *= sqrtf(pow(pTransform->e11, 2) + pow(pTransform->e21, 2)); //we know x/y scaling factors are same.
auto cnt = writeTagProperty(TVG_TAG_SHAPE_STROKE_WIDTH, SIZE(width), &width);
//cap