13
0

canvas: tweaks to Arc canvas item

Cairo uses 0 degrees to mean "east", so the "top" or "north" of
a circle is actually -90 degrees
This commit is contained in:
Paul Davis 2022-08-27 12:54:43 -06:00
parent b10a99dcad
commit a1f69ee63b

View File

@ -70,26 +70,29 @@ Arc::compute_bounding_box () const
void void
Arc::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const Arc::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
{ {
if (_radius <= 0.0 || _arc_degrees <= 0.0 || (!fill() && !outline())) { if (_radius <= 0.0 || (!fill() && !outline())) {
return; return;
} }
Duple c = item_to_window (Duple (_center.x, _center.y)); Duple c = item_to_window (Duple (_center.x, _center.y));
context->arc (c.x, c.y, _radius, _start_degrees * (M_PI/180.0), _arc_degrees * (M_PI/180.0)); if (_arc_degrees != _start_degrees) {
if (fill()) { context->arc (c.x, c.y, _radius, _start_degrees * (M_PI/180.0), _arc_degrees * (M_PI/180.0));
setup_fill_context (context);
if (outline()) { if (fill()) {
context->fill_preserve (); setup_fill_context (context);
} else { if (outline()) {
context->fill (); context->fill_preserve ();
} else {
context->fill ();
}
} }
}
if (outline()) { if (outline()) {
setup_outline_context (context); setup_outline_context (context);
context->stroke (); context->stroke ();
}
} }
render_children (area, context); render_children (area, context);