improve rect triangle init readability
This commit is contained in:
parent
2b3f4c58c4
commit
43707826d9
1 changed files with 11 additions and 6 deletions
|
@ -36,13 +36,18 @@ void triangle(PtkTriangle *triangle, size_t uvs_offset) {
|
|||
}
|
||||
|
||||
void rect(PtkRect *rect) {
|
||||
float x = rect->top_left.x;
|
||||
float y = rect->top_left.y;
|
||||
float w = rect->size.w;
|
||||
float h = rect->size.h;
|
||||
|
||||
PtkPos t1_positions[3];
|
||||
// top left
|
||||
t1_positions[0] = (PtkPos){ .x = rect->top_left.x, .y = rect->top_left.y };
|
||||
t1_positions[0] = (PtkPos){ .x = x, .y = y };
|
||||
// bottom left
|
||||
t1_positions[1] = (PtkPos){ .x = rect->top_left.x + rect->size.w, .y = rect->top_left.y };
|
||||
t1_positions[1] = (PtkPos){ .x = x + w, .y = y };
|
||||
// top right
|
||||
t1_positions[2] = (PtkPos){ .x = rect->top_left.x, .y = rect->top_left.y + rect->size.h };
|
||||
t1_positions[2] = (PtkPos){ .x = x, .y = y + h };
|
||||
PtkTriangle *t1 = (PtkTriangle *)ptk_triangle((PtkPos *)t1_positions, rect->color);
|
||||
t1->type = rect->type;
|
||||
|
||||
|
@ -50,11 +55,11 @@ void rect(PtkRect *rect) {
|
|||
|
||||
PtkPos t2_positions[3];
|
||||
// bottom left
|
||||
t2_positions[0] = (PtkPos){ .x = rect->top_left.x + rect->size.w, .y = rect->top_left.y };
|
||||
t2_positions[0] = (PtkPos){ .x = x + w, .y = y };
|
||||
// top right
|
||||
t2_positions[1] = (PtkPos){ .x = rect->top_left.x, .y = rect->top_left.y + rect->size.h };
|
||||
t2_positions[1] = (PtkPos){ .x = x, .y = y + h };
|
||||
// bottom right
|
||||
t2_positions[2] = (PtkPos){ .x = rect->top_left.x + rect->size.w, .y = rect->top_left.y + rect->size.h };
|
||||
t2_positions[2] = (PtkPos){ .x = x + w, .y = y + h };
|
||||
PtkTriangle *t2 = (PtkTriangle *)ptk_triangle((PtkPos *)t2_positions, rect->color);
|
||||
t2->type = rect->type;
|
||||
|
||||
|
|
Loading…
Reference in a new issue