yet another api rework, removal of integer types in public api, optionals at the end, some cleaning
This commit is contained in:
@ -36,8 +36,8 @@ void render_queue_clear(void) {
|
||||
}
|
||||
|
||||
|
||||
void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int border_thickness, Rect rect, Color color) {
|
||||
const float bt = (float)border_thickness; /* i know! */
|
||||
void draw_nine_slice(const char *texture, Vec2 corners, Rect rect, float border_thickness, Color color) {
|
||||
const float bt = border_thickness;
|
||||
const float bt2 = bt * 2; /* combined size of the two borders in an axis */
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, top_left),
|
||||
m_opt(texture_region, ((Rect) { 0, 0, bt, bt })),
|
||||
m_opt(color, color),
|
||||
@ -64,9 +64,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, top_center),
|
||||
m_opt(texture_region, ((Rect) { bt, 0, (float)texture_w - bt2, bt })),
|
||||
m_opt(texture_region, ((Rect) { bt, 0, corners.x - bt2, bt })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
|
||||
@ -79,9 +79,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, top_right),
|
||||
m_opt(texture_region, ((Rect) { (float)texture_w - bt, 0, bt, bt })),
|
||||
m_opt(texture_region, ((Rect) { corners.x - bt, 0, bt, bt })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
|
||||
@ -94,9 +94,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, center_left),
|
||||
m_opt(texture_region, ((Rect) { 0, bt, bt, (float)texture_h - bt2 })),
|
||||
m_opt(texture_region, ((Rect) { 0, bt, bt, corners.y - bt2 })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
|
||||
@ -109,9 +109,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, center_right),
|
||||
m_opt(texture_region, ((Rect) { (float)texture_w - bt, bt, bt, (float)texture_h - bt2 })),
|
||||
m_opt(texture_region, ((Rect) { corners.x - bt, bt, bt, corners.y - bt2 })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
|
||||
@ -124,9 +124,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, bottom_left),
|
||||
m_opt(texture_region, ((Rect) { 0, (float)texture_h - bt, bt, bt })),
|
||||
m_opt(texture_region, ((Rect) { 0, corners.y - bt, bt, bt })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
|
||||
@ -139,9 +139,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, bottom_center),
|
||||
m_opt(texture_region, ((Rect) { bt, (float)texture_h - bt, (float)texture_w - bt2, bt })),
|
||||
m_opt(texture_region, ((Rect) { bt, corners.y - bt, corners.x - bt2, bt })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
|
||||
@ -154,9 +154,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, bottom_right),
|
||||
m_opt(texture_region, ((Rect) { (float)texture_w - bt, (float)texture_h - bt, bt, bt })),
|
||||
m_opt(texture_region, ((Rect) { corners.x - bt, corners.y - bt, bt, bt })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
|
||||
@ -169,9 +169,9 @@ void draw_nine_slice(const char *texture_path, int texture_w, int texture_h, int
|
||||
};
|
||||
|
||||
m_sprite(
|
||||
m_set(path, texture_path),
|
||||
m_set(texture, texture),
|
||||
m_set(rect, center),
|
||||
m_opt(texture_region, ((Rect) { bt, bt, (float)texture_w - bt2, (float)texture_h - bt2 })),
|
||||
m_opt(texture_region, ((Rect) { bt, bt, corners.x - bt2, corners.y - bt2 })),
|
||||
m_opt(color, color),
|
||||
);
|
||||
}
|
||||
@ -358,18 +358,18 @@ void render(void) {
|
||||
float ratio = (float)ctx.window_dims.y / (float)ctx.base_render_height;
|
||||
int w = (int)((float)ctx.base_render_width * ratio);
|
||||
setup_viewport(
|
||||
ctx.window_dims.x / 2 - w / 2,
|
||||
(int)ctx.window_dims.x / 2 - w / 2,
|
||||
0,
|
||||
w,
|
||||
ctx.window_dims.y
|
||||
(int)ctx.window_dims.y
|
||||
);
|
||||
} else {
|
||||
float ratio = (float)ctx.window_dims.x / (float)ctx.base_render_width;
|
||||
int h = (int)((float)ctx.base_render_height * ratio);
|
||||
setup_viewport(
|
||||
0,
|
||||
ctx.window_dims.y / 2 - h / 2,
|
||||
ctx.window_dims.x,
|
||||
(int)ctx.window_dims.y / 2 - h / 2,
|
||||
(int)ctx.window_dims.x,
|
||||
h
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user