src/2d.c

changeset 215
a7c8e1727971
parent 214
9d460888a83e
--- a/src/2d.c	Fri Jul 18 18:01:41 2025 +0200
+++ b/src/2d.c	Sat Jul 19 21:29:10 2025 +0200
@@ -193,6 +193,7 @@
     asc_scene_node_init(node,
         ASC_SCENE_NODE_FUNCS(asc_rectangle),
         .pos2d = ASC_VEC2I(pos_x, pos_y),
+        .origin2d = ASC_VEC2I(args.origin_x, args.origin_y),
         .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255
                              ? ASC_RENDER_GROUP_2D_BLEND
                              : ASC_RENDER_GROUP_2D_OPAQUE
@@ -311,17 +312,17 @@
 
     float pos_x, pos_y;
     if (args.bounds.size.width + args.bounds.size.height > 0) {
-        pos_x = (float) args.bounds.pos.x;
-        pos_y = (float) args.bounds.pos.y;
         ellipsis->radii.x = (float) args.bounds.size.width / 2.f;
         ellipsis->radii.y = (float) args.bounds.size.height / 2.f;
+        pos_x = (float) args.bounds.pos.x + ellipsis->radii.x;
+        pos_y = (float) args.bounds.pos.y + ellipsis->radii.y;
     } else {
         const unsigned cx = ASC_NONZERO_OR(args.x, args.center.x);
         const unsigned cy = ASC_NONZERO_OR(args.y, args.center.y);
         const unsigned rx = ASC_NONZERO_OR(args.radius, args.radius_x);
         const unsigned ry = ASC_NONZERO_OR(args.radius, args.radius_y);
-        pos_x = (float) (cx-rx);
-        pos_y = (float) (cy-ry);
+        pos_x = (float) cx;
+        pos_y = (float) cy;
         ellipsis->radii.x = (float) rx;
         ellipsis->radii.y = (float) ry;
     }
@@ -347,6 +348,7 @@
     asc_scene_node_init(node,
         ASC_SCENE_NODE_FUNCS(asc_ellipsis),
         .pos2d = ASC_VEC2I(pos_x, pos_y),
+        .origin3d = ASC_VEC3F(ellipsis->radii.x, ellipsis->radii.y, 0), // use float to avoid cast
         .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255
                              ? ASC_RENDER_GROUP_2D_BLEND
                              : ASC_RENDER_GROUP_2D_OPAQUE

mercurial