Updated examples ex02b and ex04b
This commit is contained in:
parent
b8f6705d12
commit
907fb14c79
7 changed files with 45 additions and 31 deletions
|
@ -35,31 +35,28 @@ int main()
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// TODO: draw some shapes... with names... :P
|
DrawText("some basic shapes available on raylib", 20, 20, 20, DARKGRAY);
|
||||||
/*
|
|
||||||
void DrawPixel(int posX, int posY, Color color);
|
DrawLine(18, 42, screenWidth - 18, 42, BLACK);
|
||||||
void DrawPixelV(Vector2 position, Color color);
|
|
||||||
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color);
|
DrawCircle(screenWidth/4, 120, 35, DARKBLUE);
|
||||||
void DrawLineV(Vector2 startPos, Vector2 endPos, Color color);
|
DrawCircleGradient(screenWidth/4, 220, 60, GREEN, SKYBLUE);
|
||||||
void DrawCircle(int centerX, int centerY, float radius, Color color);
|
DrawCircleLines(screenWidth/4, 340, 80, DARKBLUE);
|
||||||
void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2);
|
|
||||||
void DrawCircleV(Vector2 center, float radius, Color color);
|
DrawRectangle(screenWidth/4*2 - 60, 100, 120, 60, RED);
|
||||||
void DrawCircleLines(int centerX, int centerY, float radius, Color color);
|
DrawRectangleGradient(screenWidth/4*2 - 90, 170, 180, 130, MAROON, GOLD);
|
||||||
void DrawRectangle(int posX, int posY, int width, int height, Color color);
|
DrawRectangleLines(screenWidth/4*2 - 40, 320, 80, 60, ORANGE);
|
||||||
void DrawRectangleRec(Rectangle rec, Color color);
|
|
||||||
void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2);
|
DrawTriangle((Vector2){screenWidth/4*3, 80},
|
||||||
void DrawRectangleV(Vector2 position, Vector2 size, Color color);
|
(Vector2){screenWidth/4*3 - 60, 150},
|
||||||
void DrawRectangleLines(int posX, int posY, int width, int height, Color color);
|
(Vector2){screenWidth/4*3 + 60, 150}, VIOLET);
|
||||||
void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color);
|
|
||||||
void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color);
|
DrawTriangleLines((Vector2){screenWidth/4*3, 160},
|
||||||
void DrawPoly(Vector2 *points, int numPoints, Color color);
|
(Vector2){screenWidth/4*3 - 20, 230},
|
||||||
void DrawPolyLine(Vector2 *points, int numPoints, Color color);
|
(Vector2){screenWidth/4*3 + 20, 230}, DARKBLUE);
|
||||||
*/
|
|
||||||
DrawRectangle(screenWidth/4 - 50, screenHeight/2 - 100, 100, 100, GOLD);
|
DrawPoly((Vector2){screenWidth/4*3, 320}, 6, 80, 0, BROWN);
|
||||||
DrawCircle(3*screenWidth/4, screenHeight/2 - 50, 50, MAROON);
|
|
||||||
|
|
||||||
DrawText("_____", 320, 280, 50, 1, BLACK);
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
BIN
examples/ex02b_basic_shapes.exe
Normal file
BIN
examples/ex02b_basic_shapes.exe
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 26 KiB |
|
@ -17,11 +17,22 @@ int main()
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
int screenWidth = 800;
|
||||||
int screenHeight = 450;
|
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");
|
InitWindow(screenWidth, screenHeight, "raylib example 04b - texture rectangle");
|
||||||
|
|
||||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
// 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
|
// Main game loop
|
||||||
|
@ -38,11 +49,17 @@ int main()
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// TODO: Comming soon...
|
DrawText("LENA", 220, 100, 20, PINK);
|
||||||
// TIP: Use DrawTextureRec() function
|
|
||||||
/*
|
DrawTexture(texture, screenWidth/2 - 256, 0, halfTrans); // Draw background image
|
||||||
void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, float scale, Color tint);
|
|
||||||
*/
|
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();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
BIN
examples/ex04b_texture_rectangle.exe
Normal file
BIN
examples/ex04b_texture_rectangle.exe
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 85 KiB |
BIN
examples/resources/lena.png
Normal file
BIN
examples/resources/lena.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 463 KiB |
Loading…
Add table
Add a link
Reference in a new issue