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



commit b8d2a595aec483283d800fc8fcb045a8c69f9544
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 | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-star-image.c b/src/gs-star-image.c
index 49c8e5dfa..15e0ef3df 100644
--- a/src/gs-star-image.c
+++ b/src/gs-star-image.c
@@ -50,18 +50,32 @@ 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_assert (G_N_ELEMENTS (small_points) == G_N_ELEMENTS (large_points));
 
        if (radius <= 0)
                return;
 
+       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]