shithub: riscv

Download patch

ref: 5a724464d99b985be45555856da3959a77aea87d
parent: c7b2ca571699879cc6e97947263b2481a378c52d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Mar 9 12:34:22 EST 2019

libmemdraw: handle memarc() phi == 0 and phi <= -360, keep alpha in bounds

--- a/sys/src/libmemdraw/arc.c
+++ b/sys/src/libmemdraw/arc.c
@@ -40,13 +40,13 @@
 	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 @@
 		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 @@
 		 * 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)