Pārlūkot izejas kodu

hacky 'fix' for scaling in rotated case

Thomas Buck 10 mēnešus atpakaļ
vecāks
revīzija
273b060ab4
1 mainītis faili ar 19 papildinājumiem un 11 dzēšanām
  1. 19
    11
      render.py

+ 19
- 11
render.py Parādīt failu

@@ -69,18 +69,26 @@ def read_image(filename, path_steps, volume_percent, angle_d):
69 69
 
70 70
     p_center = [ p_min[0] + (p_max[0] - p_min[0]) / 2, p_min[1] + (p_max[1] - p_min[1]) / 2 ]
71 71
 
72
-        # find min max for all rotations
73
-        #for segment in path:
74
-        #    p_org = [segment.end.real, segment.end.imag]
75
-        #    for a in range(0, 360, 5):
76
-        #        p = rot_p(p_center, p_org , a)
77
-        #        for i in range(0, 2):
78
-        #            if p[i] < p_min[i]:
79
-        #                p_min[i] = p[i]
80
-        #            if p[i] > p_max[i]:
81
-        #                p_max[i] = p[i]
82
-
83 72
     for path in paths:
73
+        # TODO this is not nice.
74
+        # Doing both range(0, 360, 5) and angle_d is redundant.
75
+        # But also, it bakes in the assumption of the animation
76
+        # that's specified in the Makefile.
77
+        # Ideally the animation should be handled here in the
78
+        # script instead, with proper parameters.
79
+
80
+        # find min max for all rotations
81
+        for segment in path:
82
+            p_org = [segment.end.real, segment.end.imag]
83
+            for a in range(0, 360, 5):
84
+                p = rot_p(p_center, p_org , a)
85
+                for i in range(0, 2):
86
+                    if p[i] < p_min[i]:
87
+                        p_min[i] = p[i]
88
+                    if p[i] > p_max[i]:
89
+                        p_max[i] = p[i]
90
+
91
+        # find min max for this specific rotation
84 92
         for segment in path:
85 93
             p = [segment.end.real, segment.end.imag]
86 94
             p = rot_p(p_center, p, angle_d)

Notiek ielāde…
Atcelt
Saglabāt