Fixed canvas arc and therefore piemenu drawing
I forgot to add the center point to drawing an arc which resulted in half spheres. It is now fixed and should work as intended.
This commit is contained in:
parent
730fd24746
commit
98da4841dd
@ -46,7 +46,7 @@ ui_piemenu(struct zr_context *ctx, struct zr_vec2 pos, float radius,
|
||||
float step = (2 * 3.141592654f) / (float)(MAX(1,item_count));
|
||||
float a_min = 0; float a_max = step;
|
||||
|
||||
struct zr_vec2 center = zr_vec2(bounds.x + bounds.w / 2.0f, center.y = bounds.y + bounds.h / 2.0f);
|
||||
struct zr_vec2 center = zr_vec2(bounds.x + bounds.w / 2.0f, bounds.y + bounds.h / 2.0f);
|
||||
struct zr_vec2 drag = zr_vec2(in->mouse.pos.x - center.x, in->mouse.pos.y - center.y);
|
||||
float angle = (float)atan2(drag.y, drag.x);
|
||||
if (angle < -0.0f) angle += 2.0f * 3.141592654f;
|
||||
@ -56,7 +56,7 @@ ui_piemenu(struct zr_context *ctx, struct zr_vec2 pos, float radius,
|
||||
struct zr_rect content;
|
||||
float rx, ry, dx, dy, a;
|
||||
zr_draw_arc(out, center.x, center.y, (bounds.w/2.0f),
|
||||
a_min, a_max, (active_item == i) ? zr_rgb(45,100,255) : zr_rgb(75,75,75));
|
||||
a_min, a_max, (active_item == i) ? zr_rgb(45,100,255): zr_rgb(60,60,60));
|
||||
|
||||
/* seperator line */
|
||||
rx = bounds.w/2.0f; ry = 0;
|
||||
|
@ -2586,7 +2586,7 @@ zr_canvas_path_arc_to(struct zr_canvas *list, struct zr_vec2 center,
|
||||
if (!list) return;
|
||||
if (radius == 0.0f) return;
|
||||
for (i = 0; i <= segments; ++i) {
|
||||
const float a = a_min + ((float)i / (float)segments) * (a_max - a_min);
|
||||
const float a = a_min + ((float)i / ((float)segments) * (a_max - a_min));
|
||||
const float x = center.x + (float)zr_cos(a) * radius;
|
||||
const float y = center.y + (float)zr_sin(a) * radius;
|
||||
zr_canvas_path_line_to(list, zr_vec2(x, y));
|
||||
@ -2882,6 +2882,7 @@ zr_canvas_load(struct zr_canvas *list, struct zr_context *queue,
|
||||
} break;
|
||||
case ZR_COMMAND_ARC: {
|
||||
const struct zr_command_arc *c = zr_command(arc, cmd);
|
||||
zr_canvas_path_line_to(list, zr_vec2(c->cx, c->cy));
|
||||
zr_canvas_path_arc_to(list, zr_vec2(c->cx, c->cy), c->r,
|
||||
c->a[0], c->a[1], curve_segments);
|
||||
zr_canvas_path_fill(list, c->color);
|
||||
|
Loading…
Reference in New Issue
Block a user