191 |
191 |
192 asc_ptr_cast(AscSceneNode, node, rectangle); |
192 asc_ptr_cast(AscSceneNode, node, rectangle); |
193 asc_scene_node_init(node, |
193 asc_scene_node_init(node, |
194 ASC_SCENE_NODE_FUNCS(asc_rectangle), |
194 ASC_SCENE_NODE_FUNCS(asc_rectangle), |
195 .pos2d = ASC_VEC2I(pos_x, pos_y), |
195 .pos2d = ASC_VEC2I(pos_x, pos_y), |
|
196 .origin2d = ASC_VEC2I(args.origin_x, args.origin_y), |
196 .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255 |
197 .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255 |
197 ? ASC_RENDER_GROUP_2D_BLEND |
198 ? ASC_RENDER_GROUP_2D_BLEND |
198 : ASC_RENDER_GROUP_2D_OPAQUE |
199 : ASC_RENDER_GROUP_2D_OPAQUE |
199 ); |
200 ); |
200 return node; |
201 return node; |
309 AscSceneNode *asc_ellipsis_create(struct asc_ellipsis_create_args args) { |
310 AscSceneNode *asc_ellipsis_create(struct asc_ellipsis_create_args args) { |
310 AscEllipsis *ellipsis = cxZallocDefault(sizeof(AscEllipsis)); |
311 AscEllipsis *ellipsis = cxZallocDefault(sizeof(AscEllipsis)); |
311 |
312 |
312 float pos_x, pos_y; |
313 float pos_x, pos_y; |
313 if (args.bounds.size.width + args.bounds.size.height > 0) { |
314 if (args.bounds.size.width + args.bounds.size.height > 0) { |
314 pos_x = (float) args.bounds.pos.x; |
|
315 pos_y = (float) args.bounds.pos.y; |
|
316 ellipsis->radii.x = (float) args.bounds.size.width / 2.f; |
315 ellipsis->radii.x = (float) args.bounds.size.width / 2.f; |
317 ellipsis->radii.y = (float) args.bounds.size.height / 2.f; |
316 ellipsis->radii.y = (float) args.bounds.size.height / 2.f; |
|
317 pos_x = (float) args.bounds.pos.x + ellipsis->radii.x; |
|
318 pos_y = (float) args.bounds.pos.y + ellipsis->radii.y; |
318 } else { |
319 } else { |
319 const unsigned cx = ASC_NONZERO_OR(args.x, args.center.x); |
320 const unsigned cx = ASC_NONZERO_OR(args.x, args.center.x); |
320 const unsigned cy = ASC_NONZERO_OR(args.y, args.center.y); |
321 const unsigned cy = ASC_NONZERO_OR(args.y, args.center.y); |
321 const unsigned rx = ASC_NONZERO_OR(args.radius, args.radius_x); |
322 const unsigned rx = ASC_NONZERO_OR(args.radius, args.radius_x); |
322 const unsigned ry = ASC_NONZERO_OR(args.radius, args.radius_y); |
323 const unsigned ry = ASC_NONZERO_OR(args.radius, args.radius_y); |
323 pos_x = (float) (cx-rx); |
324 pos_x = (float) cx; |
324 pos_y = (float) (cy-ry); |
325 pos_y = (float) cy; |
325 ellipsis->radii.x = (float) rx; |
326 ellipsis->radii.x = (float) rx; |
326 ellipsis->radii.y = (float) ry; |
327 ellipsis->radii.y = (float) ry; |
327 } |
328 } |
328 |
329 |
329 ellipsis->filled = args.filled; |
330 ellipsis->filled = args.filled; |
345 |
346 |
346 asc_ptr_cast(AscSceneNode, node, ellipsis); |
347 asc_ptr_cast(AscSceneNode, node, ellipsis); |
347 asc_scene_node_init(node, |
348 asc_scene_node_init(node, |
348 ASC_SCENE_NODE_FUNCS(asc_ellipsis), |
349 ASC_SCENE_NODE_FUNCS(asc_ellipsis), |
349 .pos2d = ASC_VEC2I(pos_x, pos_y), |
350 .pos2d = ASC_VEC2I(pos_x, pos_y), |
|
351 .origin3d = ASC_VEC3F(ellipsis->radii.x, ellipsis->radii.y, 0), // use float to avoid cast |
350 .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255 |
352 .render_group = (args.filled && args.color.alpha < 255) || args.border_color.alpha < 255 |
351 ? ASC_RENDER_GROUP_2D_BLEND |
353 ? ASC_RENDER_GROUP_2D_BLEND |
352 : ASC_RENDER_GROUP_2D_OPAQUE |
354 : ASC_RENDER_GROUP_2D_OPAQUE |
353 ); |
355 ); |
354 return node; |
356 return node; |