2#include "zeroerr/assert.h"
15 float u0,
float v0,
float u1,
float v1,
bool rotatedUV) {
42 const Color &
color,
float u0,
float v0,
float u1,
float v1,
44 const float rad =
degrees *
static_cast<float>(3.14159265358979323846) / 180.0f;
45 const float cos = std::cos(rad);
46 const float sin = std::sin(rad);
47 const float hw =
w * 0.5f;
48 const float hh =
h * 0.5f;
50 auto corner = [&](
float dx,
float dy) -> glm::vec2 {
51 return {
cx + dx * cos - dy * sin,
cy + dx * sin + dy * cos};
53 const glm::vec2 tl = corner(-hw, -hh);
54 const glm::vec2
tr = corner(hw, -hh);
55 const glm::vec2 bl = corner(-hw, hh);
56 const glm::vec2 br = corner(hw, hh);
82 const float rad =
degrees *
static_cast<float>(3.14159265358979323846) / 180.0f;
83 const float cos = std::cos(rad);
84 const float sin = std::sin(rad);
85 const float hw =
w * 0.5f;
86 const float hh =
h * 0.5f;
88 auto corner = [&](
float dx,
float dy) -> glm::vec2 {
89 return {
cx + dx * cos - dy * sin,
cy + dx * sin + dy * cos};
91 const glm::vec2 tl = corner(-hw, -hh);
92 const glm::vec2
tr = corner(hw, -hh);
93 const glm::vec2 bl = corner(-hw, hh);
94 const glm::vec2 br = corner(hw, hh);
100 verts.push_back(v0p);
101 verts.push_back(v1p);
102 verts.push_back(v2p);
103 verts.push_back(v1p);
104 verts.push_back(v3p);
105 verts.push_back(v2p);
109 ASSERT_GT(logicalW, 0);
110 ASSERT_GT(logicalH, 0);
111 if (logicalW <= 0 || logicalH <= 0)
return;
112 const float sx = 2.0f / float(logicalW);
113 const float sy = 2.0f / float(logicalH);
114 for (
auto &
v : verts) {
117 v.pos.x =
v.pos.x * sx - 1.0f;
118 v.pos.y =
v.pos.y * sy - 1.0f;
image::ImageData::Colorf color
void addRect(float x, float y, float w, float h, const Color &color)
void addRectRotated(float cx, float cy, float w, float h, float degrees, const Color &color)
void addTexturedRect(float x, float y, float w, float h, const Color &color, float u0, float v0, float u1, float v1, bool rotatedUV=false)
void addTexturedRectRotated(float cx, float cy, float w, float h, float degrees, const Color &color, float u0, float v0, float u1, float v1, bool rotatedUV=false)
Textured quad rotated degrees (clockwise, screen Y-down) around (cx, cy).
void toNDC(int logicalW, int logicalH)
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
glm::vec4 Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
CPU-side vertex for 2D batching (logical or NDC depending on stage).