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;