[gnome-2048] Improve a bit tile rendering.



commit 660146d063848de33fb7b781d2052c13fa7d7382
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Feb 6 13:05:52 2019 +0100

    Improve a bit tile rendering.
    
    Do not convert to degrees, and have
    better corners on non-square grids.

 src/view.vala | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/view.vala b/src/view.vala
index adc284a..5165738 100644
--- a/src/view.vala
+++ b/src/view.vala
@@ -60,10 +60,10 @@ private class RoundedRectangle : Object
             canvas.invalidate ();
     }
 
+    const double HALF_PI = Math.PI / 2.0;
     protected virtual bool _draw (Cairo.Context ctx, int width, int height)
     {
-        double radius = height / 20.0;
-        double degrees = Math.PI / 180.0;
+        double radius = (height > width) ? (height / 20.0) : (width / 20.0);
 
         ctx.save ();
         ctx.set_operator (Cairo.Operator.CLEAR);
@@ -71,10 +71,10 @@ private class RoundedRectangle : Object
         ctx.restore ();
 
         ctx.new_sub_path ();
-        ctx.arc (width - radius, radius,          radius,  -90 * degrees,   0 * degrees);
-        ctx.arc (width - radius, height - radius, radius,    0 * degrees,  90 * degrees);
-        ctx.arc (radius,         height - radius, radius,   90 * degrees, 180 * degrees);
-        ctx.arc (radius,         radius,          radius,  180 * degrees, 270 * degrees);
+        ctx.arc (radius,         radius,          radius,  Math.PI, -HALF_PI);
+        ctx.arc (width - radius, radius,          radius, -HALF_PI,        0);
+        ctx.arc (width - radius, height - radius, radius,        0,  HALF_PI);
+        ctx.arc (radius,         height - radius, radius,  HALF_PI,  Math.PI);
         ctx.close_path ();
 
         Clutter.cairo_set_source_color (ctx, (!) _color);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]