aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2013-12-20 12:50:43 +0100
committerraysan5 <raysan5@gmail.com>2013-12-20 12:50:43 +0100
commit907fb14c797c3bfcf8c9e9d46c9280c056146088 (patch)
treea053a3ff8d221fa9196a99500f95c8f4ae3a2715 /examples
parentb8f6705d126f3d80b74879abc6b4a88c0b9a8d74 (diff)
downloadraylib-907fb14c797c3bfcf8c9e9d46c9280c056146088.tar.gz
raylib-907fb14c797c3bfcf8c9e9d46c9280c056146088.zip
Updated examples ex02b and ex04b
Diffstat (limited to 'examples')
-rw-r--r--examples/ex02b_basic_shapes.c47
-rw-r--r--examples/ex02b_basic_shapes.exebin0 -> 332266 bytes
-rw-r--r--examples/ex02b_basic_shapes.pngbin3913 -> 26439 bytes
-rw-r--r--examples/ex04b_texture_rectangle.c29
-rw-r--r--examples/ex04b_texture_rectangle.exebin0 -> 324978 bytes
-rw-r--r--examples/ex04b_texture_rectangle.pngbin3913 -> 86779 bytes
-rw-r--r--examples/resources/lena.pngbin0 -> 473831 bytes
7 files changed, 45 insertions, 31 deletions
diff --git a/examples/ex02b_basic_shapes.c b/examples/ex02b_basic_shapes.c
index ce16d4c8..de70a180 100644
--- a/examples/ex02b_basic_shapes.c
+++ b/examples/ex02b_basic_shapes.c
@@ -35,31 +35,28 @@ int main()
ClearBackground(RAYWHITE);
- // TODO: draw some shapes... with names... :P
-/*
-void DrawPixel(int posX, int posY, Color color);
-void DrawPixelV(Vector2 position, Color color);
-void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color);
-void DrawLineV(Vector2 startPos, Vector2 endPos, Color color);
-void DrawCircle(int centerX, int centerY, float radius, Color color);
-void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2);
-void DrawCircleV(Vector2 center, float radius, Color color);
-void DrawCircleLines(int centerX, int centerY, float radius, Color color);
-void DrawRectangle(int posX, int posY, int width, int height, Color color);
-void DrawRectangleRec(Rectangle rec, Color color);
-void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2);
-void DrawRectangleV(Vector2 position, Vector2 size, Color color);
-void DrawRectangleLines(int posX, int posY, int width, int height, Color color);
-void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color);
-void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color);
-void DrawPoly(Vector2 *points, int numPoints, Color color);
-void DrawPolyLine(Vector2 *points, int numPoints, Color color);
-*/
- DrawRectangle(screenWidth/4 - 50, screenHeight/2 - 100, 100, 100, GOLD);
- DrawCircle(3*screenWidth/4, screenHeight/2 - 50, 50, MAROON);
-
- DrawText("_____", 320, 280, 50, 1, BLACK);
-
+ DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
+
+ DrawLine(18, 42, screenWidth - 18, 42, BLACK);
+
+ DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
+ DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE);
+ DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE);
+
+ DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
+ DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
+ DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE);
+
+ DrawTriangle((Vector2){screenWidth/4*3, 80},
+ (Vector2){screenWidth/4*3 - 60, 150},
+ (Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
+
+ DrawTriangleLines((Vector2){screenWidth/4*3, 160},
+ (Vector2){screenWidth/4*3 - 20, 230},
+ (Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
+
+ DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
+
EndDrawing();
//----------------------------------------------------------------------------------
}
diff --git a/examples/ex02b_basic_shapes.exe b/examples/ex02b_basic_shapes.exe
new file mode 100644
index 00000000..e177eee2
--- /dev/null
+++ b/examples/ex02b_basic_shapes.exe
Binary files differ
diff --git a/examples/ex02b_basic_shapes.png b/examples/ex02b_basic_shapes.png
index f18ae044..03ecf2ec 100644
--- a/examples/ex02b_basic_shapes.png
+++ b/examples/ex02b_basic_shapes.png
Binary files differ
diff --git a/examples/ex04b_texture_rectangle.c b/examples/ex04b_texture_rectangle.c
index b7011d2a..32a35e98 100644
--- a/examples/ex04b_texture_rectangle.c
+++ b/examples/ex04b_texture_rectangle.c
@@ -17,11 +17,22 @@ int main()
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
+
+ const char textLine1[] = "Lena image is a standard test image which has been in use since 1973.";
+ const char textLine2[] = "It comprises 512x512 pixels, and was originally cropped from the centerfold";
+ const char textLine3[] = "of November 1972 issue of Playboy magazine. The image is probably the most";
+ const char textLine4[] = "widely used test image for all sorts of image processing algorithms.";
InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
- Texture2D texture = LoadTexture("resources/raylib_logo.png"); // Texture loading
+ Texture2D texture = LoadTexture("resources/lena.png"); // Texture loading
+
+ Color halfTrans = WHITE;
+ halfTrans.a = 30;
+
+ Rectangle eyesRec = { 225, 240, 155, 50 };
+ Vector2 position = { 369, 241 };
//--------------------------------------------------------------------------------------
// Main game loop
@@ -38,11 +49,17 @@ int main()
ClearBackground(RAYWHITE);
- // TODO: Comming soon...
- // TIP: Use DrawTextureRec() function
-/*
-void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, float scale, Color tint);
-*/
+ DrawText("LENA", 220, 100, 20, PINK);
+
+ DrawTexture(texture, screenWidth/2 - 256, 0, halfTrans); // Draw background image
+
+ DrawTextureRec(texture, eyesRec, position, WHITE); // Draw eyes part of image
+
+ DrawText(textLine1, 220, 140, 10, DARKGRAY);
+ DrawText(textLine2, 220, 160, 10, DARKGRAY);
+ DrawText(textLine3, 220, 180, 10, DARKGRAY);
+ DrawText(textLine4, 220, 200, 10, DARKGRAY);
+
EndDrawing();
//----------------------------------------------------------------------------------
}
diff --git a/examples/ex04b_texture_rectangle.exe b/examples/ex04b_texture_rectangle.exe
new file mode 100644
index 00000000..6e747036
--- /dev/null
+++ b/examples/ex04b_texture_rectangle.exe
Binary files differ
diff --git a/examples/ex04b_texture_rectangle.png b/examples/ex04b_texture_rectangle.png
index f18ae044..ff206365 100644
--- a/examples/ex04b_texture_rectangle.png
+++ b/examples/ex04b_texture_rectangle.png
Binary files differ
diff --git a/examples/resources/lena.png b/examples/resources/lena.png
new file mode 100644
index 00000000..59ef68aa
--- /dev/null
+++ b/examples/resources/lena.png
Binary files differ