mirror of
				https://github.com/raysan5/raylib.git
				synced 2025-10-26 12:27:01 +00:00 
			
		
		
		
	Added function DrawRectangleGradientEx()
Moved function DrawRectangleT() from text module to shapes Added some comments
This commit is contained in:
		| @@ -855,8 +855,10 @@ RLAPI void DrawRectangle(int posX, int posY, int width, int height, Color color) | |||||||
| RLAPI void DrawRectangleRec(Rectangle rec, Color color);                                                 // Draw a color-filled rectangle | RLAPI void DrawRectangleRec(Rectangle rec, Color color);                                                 // Draw a color-filled rectangle | ||||||
| RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color);                 // Draw a color-filled rectangle with pro parameters | RLAPI void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color);                 // Draw a color-filled rectangle with pro parameters | ||||||
| RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle | RLAPI void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle | ||||||
|  | RLAPI void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4);       // Draw a gradient-filled rectangle with custom vertex colors | ||||||
| RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color);                                  // Draw a color-filled rectangle (Vector version) | RLAPI void DrawRectangleV(Vector2 position, Vector2 size, Color color);                                  // Draw a color-filled rectangle (Vector version) | ||||||
| RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color);                   // Draw rectangle outline | RLAPI void DrawRectangleLines(int posX, int posY, int width, int height, Color color);                   // Draw rectangle outline | ||||||
|  | RLAPI void DrawRectangleT(int posX, int posY, int width, int height, Color color);                       // Draw rectangle using text character | ||||||
| RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color);                                // Draw a color-filled triangle | RLAPI void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color);                                // Draw a color-filled triangle | ||||||
| RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color);                           // Draw triangle outline | RLAPI void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color);                           // Draw triangle outline | ||||||
| RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color);               // Draw a regular polygon (Vector version) | RLAPI void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color);               // Draw a regular polygon (Vector version) | ||||||
| @@ -952,7 +954,6 @@ RLAPI void DrawFPS(int posX, int posY); | |||||||
| RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color);                    // Draw text (using default font) | RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color);                    // Draw text (using default font) | ||||||
| RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position,                         // Draw text using SpriteFont and additional parameters | RLAPI void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position,                         // Draw text using SpriteFont and additional parameters | ||||||
|                 float fontSize, int spacing, Color tint); |                 float fontSize, int spacing, Color tint); | ||||||
| RLAPI void DrawRectangleT(int posX, int posY, int width, int height, Color color);                       // Draw rectangle using text character |  | ||||||
|  |  | ||||||
| // Text misc. functions | // Text misc. functions | ||||||
| RLAPI int MeasureText(const char *text, int fontSize);                                                   // Measure string width for default font | RLAPI int MeasureText(const char *text, int fontSize);                                                   // Measure string width for default font | ||||||
|   | |||||||
							
								
								
									
										55
									
								
								src/shapes.c
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								src/shapes.c
									
									
									
									
									
								
							| @@ -289,6 +289,53 @@ void DrawRectangleGradient(int posX, int posY, int width, int height, Color colo | |||||||
|     rlEnd(); |     rlEnd(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Draw a gradient-filled rectangle | ||||||
|  | void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4) | ||||||
|  | { | ||||||
|  |     rlEnableTexture(GetTextureDefault().id);    // Default white texture | ||||||
|  |  | ||||||
|  |     rlBegin(RL_QUADS); | ||||||
|  |         rlNormal3f(0.0f, 0.0f, 1.0f); | ||||||
|  |  | ||||||
|  |         rlColor4ub(col1.r, col1.g, col1.b, col1.a); | ||||||
|  |         rlTexCoord2f(0.0f, 0.0f); | ||||||
|  |         rlVertex2f(rec.x, rec.y); | ||||||
|  |  | ||||||
|  |         rlColor4ub(col2.r, col2.g, col2.b, col2.a); | ||||||
|  |         rlTexCoord2f(0.0f, 1.0f); | ||||||
|  |         rlVertex2f(rec.x, rec.y + rec.height); | ||||||
|  |  | ||||||
|  |         rlColor4ub(col3.r, col3.g, col3.b, col3.a); | ||||||
|  |         rlTexCoord2f(1.0f, 1.0f); | ||||||
|  |         rlVertex2f(rec.x + rec.width, rec.y + rec.height); | ||||||
|  |  | ||||||
|  |         rlColor4ub(col4.r, col4.g, col4.b, col4.a); | ||||||
|  |         rlTexCoord2f(1.0f, 0.0f); | ||||||
|  |         rlVertex2f(rec.x + rec.width, rec.y); | ||||||
|  |     rlEnd(); | ||||||
|  |      | ||||||
|  |     // Draw rectangle using font texture white character | ||||||
|  |     /* | ||||||
|  |     rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width,  | ||||||
|  |                  (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); | ||||||
|  |     rlVertex2f(rec.x, rec.y); | ||||||
|  |      | ||||||
|  |     rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width,  | ||||||
|  |                  (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); | ||||||
|  |     rlVertex2f(rec.x, rec.y + rec.height); | ||||||
|  |      | ||||||
|  |     rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width,  | ||||||
|  |                  (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); | ||||||
|  |     rlVertex2f(rec.x + rec.width, rec.y + rec.height); | ||||||
|  |      | ||||||
|  |     rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width,  | ||||||
|  |                  (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); | ||||||
|  |     rlVertex2f(rec.x + rec.width, rec.y); | ||||||
|  |     */ | ||||||
|  |                  | ||||||
|  |     rlDisableTexture(); | ||||||
|  | } | ||||||
|  |  | ||||||
| // Draw a color-filled rectangle (Vector version) | // Draw a color-filled rectangle (Vector version) | ||||||
| // NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues (view rlglDraw) | // NOTE: On OpenGL 3.3 and ES2 we use QUADS to avoid drawing order issues (view rlglDraw) | ||||||
| void DrawRectangleV(Vector2 position, Vector2 size, Color color) | void DrawRectangleV(Vector2 position, Vector2 size, Color color) | ||||||
| @@ -362,6 +409,14 @@ void DrawRectangleLines(int posX, int posY, int width, int height, Color color) | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Draw rectangle using text character (char: 127) | ||||||
|  | // NOTE: Useful to avoid changing to default white texture | ||||||
|  | void DrawRectangleT(int posX, int posY, int width, int height, Color color) | ||||||
|  | { | ||||||
|  |     DrawTexturePro(GetDefaultFont().texture, GetDefaultFont().chars[95].rec,  | ||||||
|  |                    (Rectangle){ posX, posY, width, height }, (Vector2){ 0, 0 }, 0.0f, color); | ||||||
|  | } | ||||||
|  |  | ||||||
| // Draw a triangle | // Draw a triangle | ||||||
| void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) | void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -457,14 +457,6 @@ void DrawTextEx(SpriteFont spriteFont, const char *text, Vector2 position, float | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| // Draw rectangle using text character (char: 127) |  | ||||||
| // NOTE: Useful to avoid changing to default white texture |  | ||||||
| void DrawRectangleT(int posX, int posY, int width, int height, Color color) |  | ||||||
| { |  | ||||||
|     DrawTexturePro(GetDefaultFont().texture, GetDefaultFont().chars[95].rec,  |  | ||||||
|                    (Rectangle){ posX, posY, width, height }, (Vector2){ 0, 0 }, 0.0f, color); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Formatting of text with variables to 'embed' | // Formatting of text with variables to 'embed' | ||||||
| const char *FormatText(const char *text, ...) | const char *FormatText(const char *text, ...) | ||||||
| { | { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 raysan5
					raysan5