瀏覽代碼

Added function DrawRectanglePro()

pull/229/head
Ray 8 年之前
父節點
當前提交
177af272f0
共有 1 個檔案被更改,包括 32 行新增3 行删除
  1. +32
    -3
      src/shapes.c

+ 32
- 3
src/shapes.c 查看文件

@ -4,11 +4,17 @@
* *
* Basic functions to draw 2d Shapes and check collisions * Basic functions to draw 2d Shapes and check collisions
* *
* ">External libs:
* l">DEPENDENCIES:
* rlgl - raylib OpenGL abstraction layer * rlgl - raylib OpenGL abstraction layer
* *
* Module Configuration Flags:
* ...
* CONFIGURATION:
*
* #define SUPPORT_QUADS_ONLY
*
#define SUPPORT_TRIANGLES_ONLY
*
*
* LICENSE: zlib/libpng
* *
* Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) * Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
* *
@ -190,6 +196,29 @@ void DrawRectangleRec(Rectangle rec, Color color)
DrawRectangle(rec.x, rec.y, rec.width, rec.height, color); DrawRectangle(rec.x, rec.y, rec.width, rec.height, color);
} }
void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color)
{
rlEnableTexture(GetDefaultTexture().id);
rlPushMatrix();
rlTranslatef((float)rec.x, (float)rec.y, 0);
rlRotatef(rotation, 0, 0, 1);
rlTranslatef(-origin.x, -origin.y, 0);
rlBegin(RL_QUADS);
rlColor4ub(color.r, color.g, color.b, color.a);
rlNormal3f(0.0f, 0.0f, 1.0f); // Normal vector pointing towards viewer
rlVertex2f(0.0f, 0.0f);
rlVertex2f(0.0f, (float)rec.height);
rlVertex2f((float)rec.width, (float)rec.height);
rlVertex2f((float)rec.width, 0.0f);
rlEnd();
rlPopMatrix();
rlDisableTexture();
}
// Draw a gradient-filled rectangle // Draw a gradient-filled rectangle
// NOTE: Gradient goes from bottom (color1) to top (color2) // NOTE: Gradient goes from bottom (color1) to top (color2)
void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2) void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2)

Loading…
取消
儲存