Allow float center for rotate operations by radarhere · Pull Request #8114 · python-pillow/Pillow
| angle = -math.radians(angle) | |
| matrix = [ | |
| round(math.cos(angle), 15), | |
| round(math.sin(angle), 15), | |
| 0.0, | |
| round(-math.sin(angle), 15), | |
| round(math.cos(angle), 15), | |
| 0.0, | |
| ] | |
| def transform(x, y, matrix): | |
| (a, b, c, d, e, f) = matrix | |
| return a * x + b * y + c, d * x + e * y + f | |
| matrix[2], matrix[5] = transform( | |
| -rotn_center[0] - post_trans[0], -rotn_center[1] - post_trans[1], matrix | |
| ) | |
| matrix[2] += rotn_center[0] | |
| matrix[5] += rotn_center[1] |