aboutsummaryrefslogtreecommitdiff
path: root/src/textures.c
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2018-12-26 23:44:16 +0100
committerraysan5 <raysan5@gmail.com>2018-12-26 23:44:16 +0100
commit414c3ee1f97c2c939d68b1b99a72feec1e29112a (patch)
tree2e175f24f4c63dea0dcced5f9947e1c59e23642b /src/textures.c
parent91a7b0e5ef7fbb3f58ebbf93e62512e96a5caf57 (diff)
downloadraylib-414c3ee1f97c2c939d68b1b99a72feec1e29112a.tar.gz
raylib-414c3ee1f97c2c939d68b1b99a72feec1e29112a.zip
ADDED: DrawTextureQuad()
Useful for tiling and offset parameters definition.
Diffstat (limited to 'src/textures.c')
-rw-r--r--src/textures.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/textures.c b/src/textures.c
index a7120979..726a2a84 100644
--- a/src/textures.c
+++ b/src/textures.c
@@ -2418,6 +2418,17 @@ void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Co
DrawTexturePro(texture, sourceRec, destRec, origin, 0.0f, tint);
}
+// Draw texture quad with tiling and offset parameters
+// NOTE: Tiling and offset should be provided considering normalized texture values [0..1]
+// i.e tiling = { 1.0f, 1.0f } refers to all texture, offset = { 0.5f, 0.5f } moves texture origin to center
+void DrawTextureQuad(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint)
+{
+ Rectangle source = { offset.x*texture.width, offset.y*texture.height, tiling.x*texture.width, tiling.y*texture.height };
+ Vector2 origin = { 0.0f, 0.0f };
+
+ DrawTexturePro(texture, source, quad, origin, 0.0f, tint);
+}
+
// Draw a part of a texture (defined by a rectangle) with 'pro' parameters
// NOTE: origin is relative to destination rectangle size
void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint)
@@ -2464,6 +2475,7 @@ void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, V
}
}
+// Draws a texture (or part of it) that stretches or shrinks nicely using n-patch info
void DrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle destRec, Vector2 origin, float rotation, Color tint)
{
if (texture.id > 0)