From: Philipp Zabel Date: Thu, 10 Feb 2011 16:11:37 +0000 (+0100) Subject: Fix the color widget's cairo arc draw calls X-Git-Url: http://vcs.maemo.org/git/?p=led-pattern-ed;a=commitdiff_plain;h=dd793710cd7537c6682ed01ac5b0915192da4617 Fix the color widget's cairo arc draw calls --- diff --git a/src/led-color-widgets.vala b/src/led-color-widgets.vala index 7fc0770..ab7d4e7 100644 --- a/src/led-color-widgets.vala +++ b/src/led-color-widgets.vala @@ -42,43 +42,49 @@ class LedColorWidget : Gtk.DrawingArea { var ctx = Gdk.cairo_create (window); int height = allocation.height; int width = allocation.width; - double radius = Math.fmin (width * 0.4, height * 0.4); + double radius = int.min (width, height) * 0.4; ctx.rectangle (event.area.x, event.area.y, event.area.width, event.area.height); ctx.clip (); ctx.new_path (); - ctx.arc (width / 2.0, height / 2.0, Math.fmin (width, height) / 2.0, 0, 2 * Math.PI); - + ctx.translate (width / 2.0, height / 2.0); + ctx.arc (0, 0, radius * 1.25, 0, 2 * Math.PI); ctx.clip (); ctx.set_operator (Cairo.Operator.ADD); if (LedColor.R in color) { + ctx.save (); ctx.set_source_rgb (1.0, 0, 0); ctx.new_path (); - ctx.arc (width / 2.0 + radius / 3.2 * Math.cos (270 * Math.PI / 180.0), - height / 2.0 + radius / 3.2 * Math.sin (270 * Math.PI / 180.0), - radius, 0, 2 * Math.PI); + ctx.translate (radius / 3.2 * Math.cos (270 * Math.PI / 180.0), + radius / 3.2 * Math.sin (270 * Math.PI / 180.0)); + ctx.arc (0, 0, radius, 0, 2 * Math.PI); ctx.fill (); + ctx.restore (); } if (LedColor.G in color) { + ctx.save (); ctx.set_source_rgb (0, 1.0, 0); ctx.new_path (); - ctx.arc (width / 2.0 + radius / 3.2 * Math.cos (150 * Math.PI / 180.0), - height / 2.0 + radius / 3.2 * Math.sin (150 * Math.PI / 180.0), - radius, 0, 2 * Math.PI); + ctx.translate (radius / 3.2 * Math.cos (150 * Math.PI / 180.0), + radius / 3.2 * Math.sin (150 * Math.PI / 180.0)); + ctx.arc (0, 0, radius, 0, 2 * Math.PI); ctx.fill (); + ctx.restore (); } if (LedColor.B in color) { + ctx.save (); ctx.set_source_rgb (0, 0, 1.0); ctx.new_path (); - ctx.arc (width / 2.0 + radius / 3.2 * Math.cos (30 * Math.PI / 180.0), - height / 2.0 + radius / 3.2 * Math.sin (30 * Math.PI / 180.0), - radius, 0, 2 * Math.PI); + ctx.translate (radius / 3.2 * Math.cos (30 * Math.PI / 180.0), + radius / 3.2 * Math.sin (30 * Math.PI / 180.0)); + ctx.arc (0, 0, radius, 0, 2 * Math.PI); ctx.fill (); + ctx.restore (); } return true;