Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/raylib.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,14 @@
#define ORANGE CLITERAL(Color){ 255, 161, 0, 255 } // Orange
#define PINK CLITERAL(Color){ 255, 109, 194, 255 } // Pink
#define RED CLITERAL(Color){ 230, 41, 55, 255 } // Red
#define STRONGRED CLITERAL(Color){ 255, 0, 0, 255} // Strong Red
#define MAROON CLITERAL(Color){ 190, 33, 55, 255 } // Maroon
#define GREEN CLITERAL(Color){ 0, 228, 48, 255 } // Green
#define LIME CLITERAL(Color){ 0, 158, 47, 255 } // Lime
#define DARKGREEN CLITERAL(Color){ 0, 117, 44, 255 } // Dark Green
#define SKYBLUE CLITERAL(Color){ 102, 191, 255, 255 } // Sky Blue
#define BLUE CLITERAL(Color){ 0, 121, 241, 255 } // Blue
#define CYAN CLITERAL(Color){ 0, 255, 255, 255 } // Cyan
#define DARKBLUE CLITERAL(Color){ 0, 82, 172, 255 } // Dark Blue
#define PURPLE CLITERAL(Color){ 200, 122, 255, 255 } // Purple
#define VIOLET CLITERAL(Color){ 135, 60, 190, 255 } // Violet
Expand Down Expand Up @@ -1000,6 +1002,7 @@ RLAPI void SetWindowFocused(void); // Set window
RLAPI void *GetWindowHandle(void); // Get native window handle
RLAPI int GetScreenWidth(void); // Get current screen width
RLAPI int GetScreenHeight(void); // Get current screen height
RLAPI Vector2 GetScreenCenter(void); // Get the center of the current screen
RLAPI int GetRenderWidth(void); // Get current render width (it considers HiDPI)
RLAPI int GetRenderHeight(void); // Get current render height (it considers HiDPI)
RLAPI int GetMonitorCount(void); // Get number of connected monitors
Expand Down Expand Up @@ -1042,6 +1045,8 @@ RLAPI void EndShaderMode(void); // End custom
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied, subtract, custom)
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
RLAPI void BeginScissorMode(int x, int y, int width, int height); // Begin scissor mode (define screen area for following drawing)
RLAPI void BeginScissorModeV(Vector2 position, Vector2 size); // Begin scissor mode (define screen area for following drawing with vectors)
RLAPI void BeginScissorModeRec(Rectangle rec); // Begin scissor mode (define screen area for following drawing with a rectangle)
RLAPI void EndScissorMode(void); // End scissor mode
RLAPI void BeginVrStereoMode(VrStereoConfig config); // Begin stereo rendering (requires VR simulator)
RLAPI void EndVrStereoMode(void); // End stereo rendering (requires VR simulator)
Expand Down Expand Up @@ -1450,6 +1455,8 @@ RLAPI void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle
// Color/pixel related functions
RLAPI bool ColorIsEqual(Color col1, Color col2); // Check if two colors are equal
RLAPI Color Fade(Color color, float alpha); // Get color with alpha applied, alpha goes from 0.0f to 1.0f
RLAPI Rectangle ExpandRectangle(Rectangle rec, float expand); // Expand a rectangle uniformly
RLAPI Rectangle ShrinkRectangle(Rectangle rec, float shrink); // Shrink a rectangle uniformly
RLAPI int ColorToInt(Color color); // Get hexadecimal value for a Color (0xRRGGBBAA)
RLAPI Vector4 ColorNormalize(Color color); // Get Color normalized as float [0..1]
RLAPI Color ColorFromNormalized(Vector4 normalized); // Get Color from normalized values [0..1]
Expand Down
21 changes: 21 additions & 0 deletions src/rcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,17 @@ int GetScreenHeight(void)
return CORE.Window.screen.height;
}

// Get the center of the current screen
Vector2 GetScreenCenter(void)
{
Vector2 center = (Vector2)
{
GetScreenWidth() / 2.0f,
GetScreenHeight() / 2.0f
};
return center;
}

// Get current render width which is equal to screen width*dpi scale
int GetRenderWidth(void)
{
Expand Down Expand Up @@ -1126,6 +1137,16 @@ void BeginScissorMode(int x, int y, int width, int height)
}
}

void BeginScissorModeV(Vector2 position, Vector2 size)
{
BeginScissorMode((int)position.x, (int)position.y, (int)size.x, (int)size.y);
}

void BeginScissorModeRec(Rectangle rec)
{
BeginScissorMode((int)rec.x, (int)rec.y, (int)rec.width, (int)rec.height);
}

// End scissor mode
void EndScissorMode(void)
{
Expand Down
20 changes: 20 additions & 0 deletions src/rtextures.c
Original file line number Diff line number Diff line change
Expand Up @@ -4859,6 +4859,26 @@ Color Fade(Color color, float alpha)
return result;
}

// Expand a rectangle uniformly
Rectangle ExpandRectangle(Rectangle rec, float expand)
{
rec.x -= expand / 2.0f;
rec.y -= expand / 2.0f;
rec.width += expand;
rec.height += expand;
return rec;
}

// Shrink a rectangle uniformly
Rectangle ShrinkRectangle(Rectangle rec, float shrink)
{
rec.x += shrink / 2.0f;
rec.y += shrink / 2.0f;
rec.width -= shrink;
rec.height -= shrink;
return rec;
}

// Get hexadecimal value for a Color
int ColorToInt(Color color)
{
Expand Down