rename asc_recti to just asc_rect (there won't be an asc_rectu)

Sun, 06 Jul 2025 18:49:44 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 06 Jul 2025 18:49:44 +0200
changeset 186
e9bb4d4f88a8
parent 185
7f0653d43a0d
child 187
15763968dfd5

rename asc_recti to just asc_rect (there won't be an asc_rectu)

src/ascension/2d.h file | annotate | diff | comparison | revisions
src/ascension/camera.h file | annotate | diff | comparison | revisions
src/ascension/datatypes.h file | annotate | diff | comparison | revisions
src/camera.c file | annotate | diff | comparison | revisions
src/window.c file | annotate | diff | comparison | revisions
test/snake/snake.c file | annotate | diff | comparison | revisions
--- a/src/ascension/2d.h	Sun Jul 06 18:49:08 2025 +0200
+++ b/src/ascension/2d.h	Sun Jul 06 18:49:44 2025 +0200
@@ -43,7 +43,7 @@
 } AscRectangle;
 
 struct asc_rectangle_create_args {
-    asc_recti bounds;
+    asc_rect bounds;
     int x;
     int y;
     unsigned int width;
@@ -88,7 +88,7 @@
      * Preferred over all other settings.
      * When you specify bounds, you cannot specify a center and radiuses.
      */
-    asc_recti bounds;
+    asc_rect bounds;
     /**
      * The center point of the ellipsis.
      * Preferred over x and y.
--- a/src/ascension/camera.h	Sun Jul 06 18:49:08 2025 +0200
+++ b/src/ascension/camera.h	Sun Jul 06 18:49:44 2025 +0200
@@ -32,13 +32,13 @@
 
 typedef struct asc_camera_s AscCamera;
 
-typedef asc_recti(*asc_camera_viewport_update_func)(asc_vec2u window_size);
+typedef asc_rect(*asc_camera_viewport_update_func)(asc_vec2u window_size);
 typedef void(*asc_camera_projection_update_func)(AscCamera*, asc_vec2u window_size);
 
 struct asc_camera_s {
     asc_mat4f projection;
     asc_mat4f view;
-    asc_recti viewport;
+    asc_rect viewport;
     /**
      * Function that gets invoked whenever the window sized changed.
      * Calculates the new drawing viewport.
@@ -60,7 +60,7 @@
     enum AscCameraType type;
     union {
         struct {
-            asc_recti rect;
+            asc_rect rect;
         } ortho;
         /*struct {
             TODO: implement
@@ -79,7 +79,7 @@
 
 #define asc_camera_init(camera,...) asc_camera_init_(camera, (struct asc_camera_init_args){__VA_ARGS__})
 
-void asc_camera_ortho(AscCamera *camera, asc_recti rect);
+void asc_camera_ortho(AscCamera *camera, asc_rect rect);
 
 /**
  * Shorter version of updating an orthographic camera which assumes the top right corner at (0,0).
--- a/src/ascension/datatypes.h	Sun Jul 06 18:49:08 2025 +0200
+++ b/src/ascension/datatypes.h	Sun Jul 06 18:49:44 2025 +0200
@@ -88,11 +88,11 @@
 #define ASC_VEC2U_0 (asc_vec2u){{0u, 0u}}
 #define ASC_VEC2U_1 (asc_vec2u){{1u, 1u}}
 
-typedef struct asc_recti {
+typedef struct asc_rect {
     asc_vec2i pos;
     asc_vec2u size;
-} asc_recti;
-#define ASC_RECTI(x, y, w, h) (asc_recti){ASC_VEC2I(x,y), ASC_VEC2U(w,h)}
+} asc_rect;
+#define ASC_RECT(x, y, w, h) (asc_rect){ASC_VEC2I(x,y), ASC_VEC2U(w,h)}
 
 typedef union asc_vec2f {
     struct { float x, y; };
@@ -154,7 +154,7 @@
     return v;
 }
 
-static inline asc_vec2i asc_recti_center(asc_recti rect) {
+static inline asc_vec2i asc_rect_center(asc_rect rect) {
     return ASC_VEC2I(rect.pos.x + rect.size.width/2, rect.pos.y + rect.size.height/2);
 }
 
--- a/src/camera.c	Sun Jul 06 18:49:08 2025 +0200
+++ b/src/camera.c	Sun Jul 06 18:49:44 2025 +0200
@@ -31,7 +31,7 @@
 
 void asc_camera_init_(AscCamera *camera, struct asc_camera_init_args args) {
     if (args.type == ASC_CAMERA_ORTHO) {
-        asc_recti rect = args.ortho.rect;
+        asc_rect rect = args.ortho.rect;
         if (rect.size.width <= 0 || rect.size.height <= 0) {
             rect.size.width = 1;
             rect.size.height = 1;
@@ -50,7 +50,7 @@
     camera->clear_color = asc_col_itof(asc_context.ink);
 }
 
-void asc_camera_ortho(AscCamera *camera, asc_recti rect) {
+void asc_camera_ortho(AscCamera *camera, asc_rect rect) {
     asc_mat4f_unit(camera->view);
     float left = (float) rect.pos.x;
     float right = left + (float) rect.size.width;
--- a/src/window.c	Sun Jul 06 18:49:08 2025 +0200
+++ b/src/window.c	Sun Jul 06 18:49:44 2025 +0200
@@ -83,7 +83,7 @@
     if (asc_gl_context_initialize(&window->glctx, window->window, &settings->glsettings)) {
         asc_scene_init(&window->ui,
             .type = ASC_CAMERA_ORTHO,
-            .ortho.rect = ASC_RECTI(0, 0, window->dimensions.width, window->dimensions.height),
+            .ortho.rect = ASC_RECT(0, 0, window->dimensions.width, window->dimensions.height),
             .projection_update_func = asc_camera_ortho_update_size
         );
         asc_dprintf("Window %u initialized at index %u", window->id, index);
--- a/test/snake/snake.c	Sun Jul 06 18:49:08 2025 +0200
+++ b/test/snake/snake.c	Sun Jul 06 18:49:44 2025 +0200
@@ -130,7 +130,7 @@
     // TODO: return something
 }
 
-static asc_recti update_viewport_for_window_resize(asc_vec2u window_size) {
+static asc_rect update_viewport_for_window_resize(asc_vec2u window_size) {
     // Compute scaling and offsets
     unsigned viewport_size, offset_x = 0, offset_y = 0;
     if (window_size.width > window_size.height) {
@@ -144,7 +144,7 @@
     }
 
     // Set the viewport to the scaled and centered region
-    return ASC_RECTI(offset_x, offset_y, viewport_size, viewport_size);
+    return ASC_RECT(offset_x, offset_y, viewport_size, viewport_size);
 }
 
 int main(void) {
@@ -179,7 +179,7 @@
     asc_ink_rgb(0, 128, 90);
     asc_scene_init(MAIN_SCENE,
         .type = ASC_CAMERA_ORTHO,
-        .ortho.rect = ASC_RECTI(0, 0, game_field_size, game_field_size),
+        .ortho.rect = ASC_RECT(0, 0, game_field_size, game_field_size),
         .viewport_clear = true,
         .viewport_update_func = update_viewport_for_window_resize
     );

mercurial