aboutsummaryrefslogtreecommitdiff
path: root/src/shapes.c
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2014-09-03 16:51:28 +0200
committerraysan5 <raysan5@gmail.com>2014-09-03 16:51:28 +0200
commitd2b98fbb5ce8d82bb2c46f3d66ffda58d6ad5c6f (patch)
tree164098ab2ecc481353ff43fdcc614ca80d2ad3ad /src/shapes.c
parent222995c32e696f04c4dd2d77141758d6591e2fe9 (diff)
downloadraylib-d2b98fbb5ce8d82bb2c46f3d66ffda58d6ad5c6f.tar.gz
raylib-d2b98fbb5ce8d82bb2c46f3d66ffda58d6ad5c6f.zip
Removed useless spaces
Diffstat (limited to 'src/shapes.c')
-rw-r--r--src/shapes.c114
1 files changed, 57 insertions, 57 deletions
diff --git a/src/shapes.c b/src/shapes.c
index 7d4c0d04..17210f21 100644
--- a/src/shapes.c
+++ b/src/shapes.c
@@ -3,17 +3,17 @@
* raylib.shapes
*
* Basic functions to draw 2d Shapes and check collisions
-*
+*
* Copyright (c) 2013 Ramon Santamaria (Ray San - raysan@raysanweb.com)
-*
-* This software is provided "as-is", without any express or implied warranty. In no event
+*
+* This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software.
*
-* Permission is granted to anyone to use this software for any purpose, including commercial
+* Permission is granted to anyone to use this software for any purpose, including commercial
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
*
-* 1. The origin of this software must not be misrepresented; you must not claim that you
-* wrote the original software. If you use this software in a product, an acknowledgment
+* 1. The origin of this software must not be misrepresented; you must not claim that you
+* wrote the original software. If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
@@ -28,7 +28,7 @@
#include <stdlib.h> // Required for abs() function
#include <math.h> // Math related functions, sin() and cos() used on DrawCircle*
// sqrt() and pow() and abs() used on CheckCollision*
-
+
#include "rlgl.h" // raylib OpenGL abstraction layer to OpenGL 1.1, 3.3+ or ES2
// Security check in case no USE_OPENGL_* defined
@@ -110,7 +110,7 @@ void DrawCircle(int centerX, int centerY, float radius, Color color)
// NOTE: Gradient goes from center (color1) to border (color2)
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2)
{
- rlBegin(RL_TRIANGLES);
+ rlBegin(RL_TRIANGLES);
for (int i=0; i < 360; i += 2)
{
rlColor4ub(color1.r, color1.g, color1.b, color1.a);
@@ -142,7 +142,7 @@ void DrawCircleLines(int centerX, int centerY, float radius, Color color)
{
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
-
+
// NOTE: Circle outline is drawn pixel by pixel every degree (0 to 360)
for (int i=0; i < 360; i++)
{
@@ -165,7 +165,7 @@ void DrawRectangle(int posX, int posY, int width, int height, Color color)
void DrawRectangleRec(Rectangle rec, Color color)
{
DrawRectangle(rec.x, rec.y, rec.width, rec.height, color);
-}
+}
// Draw a gradient-filled rectangle
// NOTE: Gradient goes from bottom (color1) to top (color2)
@@ -175,9 +175,9 @@ void DrawRectangleGradient(int posX, int posY, int width, int height, Color colo
rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX, posY);
rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX, posY + height);
rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX + width, posY + height);
-
+
rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX, posY);
- rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX + width, posY + height);
+ rlColor4ub(color2.r, color2.g, color2.b, color2.a); rlVertex2i(posX + width, posY + height);
rlColor4ub(color1.r, color1.g, color1.b, color1.a); rlVertex2i(posX + width, posY);
rlEnd();
}
@@ -188,16 +188,16 @@ void DrawRectangleV(Vector2 position, Vector2 size, Color color)
#ifdef USE_OPENGL_11
rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a);
-
+
rlVertex2i(position.x, position.y);
rlVertex2i(position.x, position.y + size.y);
rlVertex2i(position.x + size.x, position.y + size.y);
-
+
rlVertex2i(position.x, position.y);
- rlVertex2i(position.x + size.x, position.y + size.y);
+ rlVertex2i(position.x + size.x, position.y + size.y);
rlVertex2i(position.x + size.x, position.y);
rlEnd();
-#endif
+#endif
#if defined(USE_OPENGL_33) || defined(USE_OPENGL_ES2)
// NOTE: This shape uses QUADS to avoid drawing order issues (view rlglDraw)
@@ -206,17 +206,17 @@ void DrawRectangleV(Vector2 position, Vector2 size, Color color)
rlBegin(RL_QUADS);
rlColor4ub(color.r, color.g, color.b, color.a);
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal Pointing Towards Viewer
-
- rlTexCoord2f(0.0f, 0.0f);
+
+ rlTexCoord2f(0.0f, 0.0f);
rlVertex2f(position.x, position.y);
-
- rlTexCoord2f(0.0f, 1.0f);
+
+ rlTexCoord2f(0.0f, 1.0f);
rlVertex2f(position.x, position.y + size.y);
-
- rlTexCoord2f(1.0f, 1.0f);
- rlVertex2f(position.x + size.x, position.y + size.y);
-
- rlTexCoord2f(1.0f, 0.0f);
+
+ rlTexCoord2f(1.0f, 1.0f);
+ rlVertex2f(position.x + size.x, position.y + size.y);
+
+ rlTexCoord2f(1.0f, 0.0f);
rlVertex2f(position.x + size.x, position.y);
rlEnd();
@@ -231,13 +231,13 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color)
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2i(posX + 1, posY + 1);
rlVertex2i(posX + width, posY + 1);
-
+
rlVertex2i(posX + width, posY + 1);
rlVertex2i(posX + width, posY + height);
-
+
rlVertex2i(posX + width, posY + height);
rlVertex2i(posX + 1, posY + height);
-
+
rlVertex2i(posX + 1, posY + height);
rlVertex2i(posX + 1, posY + 1);
rlEnd();
@@ -260,10 +260,10 @@ void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2f(v1.x, v1.y);
rlVertex2f(v2.x, v2.y);
-
+
rlVertex2f(v2.x, v2.y);
rlVertex2f(v3.x, v3.y);
-
+
rlVertex2f(v3.x, v3.y);
rlVertex2f(v1.x, v1.y);
rlEnd();
@@ -277,12 +277,12 @@ void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color col
rlPushMatrix();
rlTranslatef(center.x, center.y, 0.0);
rlRotatef(rotation, 0, 0, 1);
-
+
rlBegin(RL_TRIANGLES);
for (int i=0; i < 360; i += 360/sides)
{
rlColor4ub(color.r, color.g, color.b, color.a);
-
+
rlVertex2i(0, 0);
rlVertex2f(sin(DEG2RAD*i) * radius, cos(DEG2RAD*i) * radius);
rlVertex2f(sin(DEG2RAD*(i+360/sides)) * radius, cos(DEG2RAD*(i+360/sides)) * radius);
@@ -299,7 +299,7 @@ void DrawPolyEx(Vector2 *points, int numPoints, Color color)
{
rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a);
-
+
for (int i = 0; i < numPoints - 2; i++)
{
rlVertex2f(points[i].x, points[i].y);
@@ -311,14 +311,14 @@ void DrawPolyEx(Vector2 *points, int numPoints, Color color)
}
// Draw polygon lines
-// NOTE: Array num elements MUST be passed as parameter to function
+// NOTE: Array num elements MUST be passed as parameter to function
void DrawPolyExLines(Vector2 *points, int numPoints, Color color)
{
if (numPoints >= 2)
{
rlBegin(RL_LINES);
rlColor4ub(color.r, color.g, color.b, color.a);
-
+
for (int i = 0; i < numPoints - 1; i++)
{
rlVertex2f(points[i].x, points[i].y);
@@ -336,9 +336,9 @@ void DrawPolyExLines(Vector2 *points, int numPoints, Color color)
bool CheckCollisionPointRec(Vector2 point, Rectangle rec)
{
bool collision = false;
-
+
if ((point.x >= rec.x) && (point.x <= (rec.x + rec.width)) && (point.y >= rec.y) && (point.y <= (rec.y + rec.height))) collision = true;
-
+
return collision;
}
@@ -355,14 +355,14 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
float alpha = ((p2.y - p3.y)*(point.x - p3.x) + (p3.x - p2.x)*(point.y - p3.y)) /
((p2.y - p3.y)*(p1.x - p3.x) + (p3.x - p2.x)*(p1.y - p3.y));
-
+
float beta = ((p3.y - p1.y)*(point.x - p3.x) + (p1.x - p3.x)*(point.y - p3.y)) /
((p2.y - p3.y)*(p1.x - p3.x) + (p3.x - p2.x)*(p1.y - p3.y));
-
+
float gamma = 1.0f - alpha - beta;
if ((alpha > 0) && (beta > 0) & (gamma > 0)) collision = true;
-
+
return collision;
}
@@ -370,12 +370,12 @@ bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2
bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2)
{
bool collision = false;
-
+
int dx = abs((rec1.x + rec1.width / 2) - (rec2.x + rec2.width / 2));
int dy = abs((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;
-
+
return collision;
}
@@ -383,14 +383,14 @@ bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2)
bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2)
{
bool collision = false;
-
+
float dx = center2.x - center1.x; // X distance between centers
float dy = center2.y - center1.y; // Y distance between centers
-
+
float distance = sqrt(dx*dx + dy*dy); // Distance between centers
-
+
if (distance <= (radius1 + radius2)) collision = true;
-
+
return collision;
}
@@ -398,12 +398,12 @@ bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, floa
bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
{
bool collision = false;
-
+
float dx = abs((rec.x + rec.width / 2) - center.x);
float dy = abs((rec.y + rec.height / 2) - center.y);
-
+
if ((dx <= (rec.width / 2 + radius)) && (dy <= (rec.height / 2 + radius))) collision = true;
-
+
return collision;
}
@@ -411,16 +411,16 @@ bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
{
Rectangle retRec = { 0, 0, 0, 0 };
-
+
if (CheckCollisionRecs(rec1, rec2))
{
int dxx = abs(rec1.x - rec2.x);
int dyy = abs(rec1.y - rec2.y);
-
+
if (rec1.x <= rec2.x)
{
if (rec1.y <= rec2.y)
- {
+ {
retRec.x = rec2.x;
retRec.y = rec2.y;
retRec.width = rec1.width - dxx;
@@ -437,7 +437,7 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
else
{
if (rec1.y <= rec2.y)
- {
+ {
retRec.x = rec1.x;
retRec.y = rec2.y;
retRec.width = rec2.width - dxx;
@@ -451,10 +451,10 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
retRec.height = rec2.height - dyy;
}
}
-
+
if (retRec.width >= rec2.width) retRec.width = rec2.width;
if (retRec.height >= rec2.height) retRec.height = rec2.height;
}
-
+
return retRec;
-}
+}