src/2d.c

changeset 214
9d460888a83e
parent 207
4d184a8706b1
child 215
a7c8e1727971
--- a/src/2d.c	Thu Jul 17 20:26:39 2025 +0200
+++ b/src/2d.c	Fri Jul 18 18:01:41 2025 +0200
@@ -28,7 +28,6 @@
 #include "ascension/2d.h"
 
 #include "ascension/constants.h"
-#include "ascension/context.h"
 #include "ascension/error.h"
 #include "ascension/shader.h"
 
@@ -173,8 +172,6 @@
     }
 
     rectangle->radius = (float)args.radius;
-    rectangle->color = asc_col_itof(asc_context.ink);
-    rectangle->border_color = asc_col_itof(args.border_color);
     rectangle->filled = args.filled;
     if (!args.filled && args.thickness == 0) {
         // when we do not fill the rectangle, we need a border
@@ -182,18 +179,21 @@
     } else {
         rectangle->thickness = args.thickness;
     }
+
     if (!args.filled && asc_memcmpz(&args.border_color, sizeof(args.border_color))) {
         // convenience fallback:
         // when we are drawing an outline but have no explicit border color,
-        // use the active ink
-        rectangle->border_color = rectangle->color;
+        // use the main color
+        args.border_color = args.color;
     }
+    rectangle->color = asc_col_itof(args.color);
+    rectangle->border_color = asc_col_itof(args.border_color);
 
     asc_ptr_cast(AscSceneNode, node, rectangle);
     asc_scene_node_init(node,
         ASC_SCENE_NODE_FUNCS(asc_rectangle),
         .pos2d = ASC_VEC2I(pos_x, pos_y),
-        .render_group = asc_context.ink.alpha < 255
+        .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255
                              ? ASC_RENDER_GROUP_2D_BLEND
                              : ASC_RENDER_GROUP_2D_OPAQUE
     );
@@ -326,8 +326,6 @@
         ellipsis->radii.y = (float) ry;
     }
 
-    ellipsis->color = asc_col_itof(asc_context.ink);
-    ellipsis->border_color = asc_col_itof(args.border_color);
     ellipsis->filled = args.filled;
     if (!args.filled && args.thickness == 0) {
         // when we do not fill the ellipsis, we need a border
@@ -335,18 +333,21 @@
     } else {
         ellipsis->thickness = args.thickness;
     }
+
     if (!args.filled && asc_memcmpz(&args.border_color, sizeof(args.border_color))) {
         // convenience fallback:
         // when we are drawing an outline but have no explicit border color,
-        // use the active ink
-        ellipsis->border_color = ellipsis->color;
+        // use the main color
+        args.border_color = args.color;
     }
+    ellipsis->color = asc_col_itof(args.color);
+    ellipsis->border_color = asc_col_itof(args.border_color);
 
     asc_ptr_cast(AscSceneNode, node, ellipsis);
     asc_scene_node_init(node,
         ASC_SCENE_NODE_FUNCS(asc_ellipsis),
         .pos2d = ASC_VEC2I(pos_x, pos_y),
-        .render_group = asc_context.ink.alpha < 255
+        .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255
                              ? ASC_RENDER_GROUP_2D_BLEND
                              : ASC_RENDER_GROUP_2D_OPAQUE
     );

mercurial