summaryrefslogtreecommitdiffhomepage
path: root/src/shapes.c
diff options
context:
space:
mode:
authorRay <[email protected]>2018-08-06 20:43:28 +0200
committerGitHub <[email protected]>2018-08-06 20:43:28 +0200
commit61b32e45ed9f28c2d41a0d004032941ab27780a3 (patch)
tree919cae03feed99f32eadaba16ac3407ee2b1a602 /src/shapes.c
parentd4bb444fe502c85e1b93e27da58d965ed7b76e74 (diff)
parentf5f7ed79b820209e8d1cda0159b3d42d2aff196b (diff)
downloadraylib-61b32e45ed9f28c2d41a0d004032941ab27780a3.tar.gz
raylib-61b32e45ed9f28c2d41a0d004032941ab27780a3.zip
Merge pull request #618 from kimkulling/fix_compiler_warnings
Fix compiler warnings
Diffstat (limited to 'src/shapes.c')
-rw-r--r--src/shapes.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/shapes.c b/src/shapes.c
index 424fb0ba..1b3862cc 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -153,9 +153,9 @@ void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
for (int i = 1; i <= LINE_DIVISIONS; i++)
{
// Cubic easing in-out
- // NOTE: Easing is calcutated only for y position value
- current.y = EaseCubicInOut(i, startPos.y, endPos.y - startPos.y, LINE_DIVISIONS);
- current.x = previous.x + (endPos.x - startPos.x)/LINE_DIVISIONS;
+ // NOTE: Easing is calculated only for y position value
+ current.y = EaseCubicInOut((float)i, startPos.y, endPos.y - startPos.y, (float) LINE_DIVISIONS);
+ current.x = previous.x + (endPos.x - startPos.x)/ (float) LINE_DIVISIONS;
DrawLineEx(previous, current, thick, color);
@@ -324,7 +324,7 @@ void DrawRectangleV(Vector2 position, Vector2 size, Color color)
// Draw a color-filled rectangle
void DrawRectangleRec(Rectangle rec, Color color)
{
- DrawRectangle(rec.x, rec.y, rec.width, rec.height, color);
+ DrawRectangle((int)rec.x, (int)rec.y, (int)rec.width, (int)rec.height, color);
}
void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color)
@@ -354,14 +354,14 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
// NOTE: Gradient goes from bottom (color1) to top (color2)
void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2)
{
- DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color2, color2, color1);
+ DrawRectangleGradientEx((Rectangle){ (float)posX, (float)posY, (float)width, (float)height }, color1, color2, color2, color1);
}
// Draw a horizontal-gradient-filled rectangle
// NOTE: Gradient goes from bottom (color1) to top (color2)
void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2)
{
- DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color1, color2, color2);
+ DrawRectangleGradientEx((Rectangle){ (float)posX, (float)posY, (float)width, (float)height }, color1, color1, color2, color2);
}
// Draw a gradient-filled rectangle
@@ -457,14 +457,14 @@ void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color)
{
if (lineThick > rec.width || lineThick > rec.height)
{
- if(rec.width > rec.height) lineThick = rec.height/2;
- else if (rec.width < rec.height) lineThick = rec.width/2;
+ if(rec.width > rec.height) lineThick = (int)rec.height/2;
+ else if (rec.width < rec.height) lineThick = (int)rec.width/2;
}
- DrawRectangle(rec.x, rec.y, rec.width, lineThick, color);
- DrawRectangle(rec.x - lineThick + rec.width, rec.y + lineThick, lineThick, rec.height - lineThick*2, color);
- DrawRectangle(rec.x, rec.y + rec.height - lineThick, rec.width, lineThick, color);
- DrawRectangle(rec.x, rec.y + lineThick, lineThick, rec.height - lineThick*2, color);
+ DrawRectangle( (int)rec.x, (int)rec.y, (int)rec.width, lineThick, color);
+ DrawRectangle( (int)(rec.x - lineThick + rec.width), (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2.0f), color);
+ DrawRectangle( (int)rec.x, (int)(rec.y + rec.height - lineThick), (int)rec.width, lineThick, color);
+ DrawRectangle( (int)rec.x, (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2), color);
}
// Draw a triangle
@@ -648,8 +648,8 @@ bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2)
{
bool collision = false;
- float dx = fabs((rec1.x + rec1.width/2) - (rec2.x + rec2.width/2));
- float dy = fabs((rec1.y + rec1.height/2) - (rec2.y + rec2.height/2));
+ float dx = (float)fabs((rec1.x + rec1.width/2) - (rec2.x + rec2.width/2));
+ float dy = (float)fabs((rec1.y + rec1.height/2) - (rec2.y + rec2.height/2));
if ((dx <= (rec1.width/2 + rec2.width/2)) && ((dy <= (rec1.height/2 + rec2.height/2)))) collision = true;
@@ -675,11 +675,11 @@ bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, floa
// NOTE: Reviewed version to take into account corner limit case
bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
{
- int recCenterX = rec.x + rec.width/2;
- int recCenterY = rec.y + rec.height/2;
+ int recCenterX = (int)(rec.x + rec.width/2.0f);
+ int recCenterY = (int)(rec.y + rec.height/2.0f);
- float dx = fabs(center.x - recCenterX);
- float dy = fabs(center.y - recCenterY);
+ float dx = (float)fabs(center.x - recCenterX);
+ float dy = (float)fabs(center.y - recCenterY);
if (dx > (rec.width/2.0f + radius)) { return false; }
if (dy > (rec.height/2.0f + radius)) { return false; }
@@ -700,8 +700,8 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
if (CheckCollisionRecs(rec1, rec2))
{
- float dxx = fabs(rec1.x - rec2.x);
- float dyy = fabs(rec1.y - rec2.y);
+ float dxx = (float)fabs(rec1.x - rec2.x);
+ float dyy = (float)fabs(rec1.y - rec2.y);
if (rec1.x <= rec2.x)
{
@@ -768,8 +768,8 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
// NOTE: Required for DrawLineBezier()
static float EaseCubicInOut(float t, float b, float c, float d)
{
- if ((t /= 0.5*d) < 1)
- return 0.5*c*t*t*t + b;
+ if ((t /= 0.5f*d) < 1)
+ return 0.5f*c*t*t*t + b;
t -= 2;
- return 0.5*c*(t*t*t + 2) + b;
+ return 0.5f*c*(t*t*t + 2.0f) + b;
}