From f734d21fa430ba105034698fd5d580cd2bd4a400 Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sat, 15 Aug 2020 15:08:19 -0700 Subject: [PATCH] Shapes from corner getting closer Circle & ellipse working well. Square and rectangle not, yet. --- src/tuxpaint.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 9f35091f3..ce7ee851a 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -12834,6 +12834,11 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) rx = abs(nx - sx); ry = abs(ny - sy); + if (shape_mode == SHAPEMODE_CORNER) + { + rx = sqrt(rx * rx) / 2; + ry = sqrt(ry * ry) / 2; + } /* If the shape has a 1:1 ("locked") aspect ratio, use the larger radius: */ @@ -12854,6 +12859,11 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) ry = 15; } + if (rx < 2) + rx = 2; + if (ry < 2) + ry = 2; + /* Render a default brush: */ @@ -12889,9 +12899,26 @@ static void do_shape(int sx, int sy, int nx, int ny, int rotn, int use_brush) offx = 0; offy = 0; } else { - /* FIXME: This needs help! */ offx = (nx - sx) / 2; offy = (ny - sy) / 2; + + if (shape_locked[cur_shape]) + { + if (abs(offx) > abs(offy)) + { + if (offy > 0) + offy = abs(offx); + else + offy = -abs(offx); + } + else + { + if (offx > 0) + offx = abs(offy); + else + offx = -abs(offy); + } + } } for (side = 0; side < shape_sides[cur_shape]; side = side + step)