[gnome-software/1299-star-image-top-point-is-shorter-than-others] gs-star-image: Change drawing for large sizes




commit 2f661699577627074456369af79d05d824ddeed3
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jun 29 15:07:58 2021 +0200

    gs-star-image: Change drawing for large sizes
    
    Let it draw slightly different shape for the small and the large sizes,
    which fit them the best.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1299

 src/gs-star-image.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-star-image.c b/src/gs-star-image.c
index 49c8e5dfa..332ad3002 100644
--- a/src/gs-star-image.c
+++ b/src/gs-star-image.c
@@ -50,18 +50,34 @@ gs_star_image_outline_star (cairo_t *cr,
         * and will be scaled to @radius when drawn. */
        const struct _points {
                gdouble x, y;
-       } points[] = {
+       } small_points[] = {
                {  0.000000, -1.000000 },
                { -1.000035, -0.424931 },
                { -0.668055,  0.850680 },
                {  0.668055,  0.850680 },
                {  1.000035, -0.424931 }
-       };
-       gint ii, nn = G_N_ELEMENTS (points), xx, yy;
+       }, large_points[] = {
+               {  0.000000, -1.000000 },
+               { -1.000035, -0.325033 },
+               { -0.618249,  0.850948 },
+               {  0.618249,  0.850948 },
+               {  1.000035, -0.325033 }
+       }, *points;
+       gint ii, nn = G_N_ELEMENTS (small_points), xx, yy;
+
+       /* Safety check */
+       G_STATIC_ASSERT (G_N_ELEMENTS (small_points) == G_N_ELEMENTS (large_points));
 
        if (radius <= 0)
                return;
 
+       /* An arbitrary number, since which the math-precise star looks fine,
+        * while it looks odd for lower sizes. */
+       if (radius * 2 > 20)
+               points = large_points;
+       else
+               points = small_points;
+
        cairo_translate (cr, radius, radius);
 
        xx = points[0].x * radius;


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