diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-03-09 17:34:22 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-03-09 17:34:22 +0100 |
commit | 5a724464d99b985be45555856da3959a77aea87d (patch) | |
tree | 0ccecce002e11b68f18e2529a0f77c4f4228b6c5 /sys/src/libmemdraw | |
parent | c7b2ca571699879cc6e97947263b2481a378c52d (diff) |
libmemdraw: handle memarc() phi == 0 and phi <= -360, keep alpha in bounds
Diffstat (limited to 'sys/src/libmemdraw')
-rw-r--r-- | sys/src/libmemdraw/arc.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/src/libmemdraw/arc.c b/sys/src/libmemdraw/arc.c index a0854c0f6..fc7363b61 100644 --- a/sys/src/libmemdraw/arc.c +++ b/sys/src/libmemdraw/arc.c @@ -40,13 +40,13 @@ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int Point p, bnd[8]; Memimage *wedge, *figure, *mask; - if(a < 0) - a = -a; - if(b < 0) - b = -b; - w = t; - if(w < 0) - w = 0; + if(phi == 0) + return; + if(phi <= -360 || phi >= 360){ + memellipse(dst, c, a, b, t, src, sp, op); + return; + } + alpha %= 360; alpha = -alpha; /* compensate for upside-down coords */ phi = -phi; beta = alpha + phi; @@ -56,10 +56,6 @@ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int beta = tmp; phi = -phi; } - if(phi >= 360){ - memellipse(dst, c, a, b, t, src, sp, op); - return; - } while(alpha < 0) alpha += 360; while(beta < 0) @@ -70,6 +66,15 @@ memarc(Memimage *dst, Point c, int a, int b, int t, Memimage *src, Point sp, int * icossin returns point at radius ICOSSCALE. * multiplying by m1 moves it outside the ellipse */ + + if(a < 0) + a = -a; + if(b < 0) + b = -b; + w = t; + if(w < 0) + w = 0; + rect = Rect(-a-w, -b-w, a+w+1, b+w+1); m = rect.max.x; /* inradius of bounding square */ if(m < rect.max.y) |