Commits

Remi Collet  committed 9e32495

more legible, I think (angle_rounded not used elsewhere)

  • Participants
  • Parent commits 4e00e33

Comments (0)

Files changed (1)

File src/gd_interpolation.c

 
 BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor)
 {
-	const int angle_rounded = (int)floor(angle * 100);
+	const int angle_rounded = (int)floor(angle);
  1. Pierre Joye

    Idea here is to keep 2 decimals for the rotation angle, useful for smooth anims for example. One degree at a time is a too large diff to get smooth moves.

      1. Pierre Joye

        hm, it is used in the case, but not for imagerotate itself. It is about getting the zero rotation, or multiple of 90 degrees rotations, with a 2 decimals precision (270.0001 will be 270).

        That being said, using the actual scale for the angle can make the code more clear :)

 	
 	if (bgcolor < 0) {
 		return NULL;
 	/* no interpolation needed here */
 	switch (angle_rounded) {
 
-		case  36000:
-		case -36000:
-		case      0: {
+		case  360:
+		case -360:
+		case    0: {
 			gdImagePtr dst = gdImageClone(src);
 
 			if (dst == NULL) {
 			return dst;
 		}
 
-		case -27000:
-		case   9000:
+		case -270:
+		case   90:
 			return gdImageRotate90(src, 0);
 
-		case -18000:
-		case  18000:
+		case -180:
+		case  180:
 			return gdImageRotate180(src, 0);
 
-		case -9000:
-		case 27000:
+		case  -90:
+		case  270:
 			return gdImageRotate270(src, 0);
 	}