mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Sped up get_pathstring of camera
This commit is contained in:
parent
5af31c1b8b
commit
d35ba7b196
1 changed files with 15 additions and 14 deletions
|
@ -179,6 +179,7 @@ class Camera(object):
|
||||||
def capture_mobject(self, mobject, **kwargs):
|
def capture_mobject(self, mobject, **kwargs):
|
||||||
return self.capture_mobjects([mobject], **kwargs)
|
return self.capture_mobjects([mobject], **kwargs)
|
||||||
|
|
||||||
|
@profile
|
||||||
def capture_mobjects(self, mobjects, **kwargs):
|
def capture_mobjects(self, mobjects, **kwargs):
|
||||||
self.reset_aggdraw_canvas()
|
self.reset_aggdraw_canvas()
|
||||||
mobjects = self.get_mobjects_to_display(mobjects, **kwargs)
|
mobjects = self.get_mobjects_to_display(mobjects, **kwargs)
|
||||||
|
@ -269,20 +270,18 @@ class Camera(object):
|
||||||
# points = self.adjust_out_of_range_points(points)
|
# points = self.adjust_out_of_range_points(points)
|
||||||
if len(points) == 0:
|
if len(points) == 0:
|
||||||
continue
|
continue
|
||||||
points = self.align_points_to_camera(points)
|
aligned_points = self.align_points_to_camera(points)
|
||||||
coords = self.points_to_pixel_coords(points)
|
coords = self.points_to_pixel_coords(aligned_points)
|
||||||
start = "M%d %d"%tuple(coords[0])
|
coord_strings = coords.flatten().astype("string")
|
||||||
#(handle1, handle2, anchor) tripletes
|
#Start new path string with M
|
||||||
triplets = zip(*[
|
coord_strings[0] = "M" + coord_strings[0]
|
||||||
coords[i+1::3]
|
#The C at the start of every 6th number communicates
|
||||||
for i in range(3)
|
#that the following 6 define a cubic Bezier
|
||||||
])
|
coord_strings[2::6] = map(lambda s : "C" + str(s), coord_strings[2::6])
|
||||||
cubics = [
|
#Possibly finish with "Z"
|
||||||
"C" + " ".join(map(str, it.chain(*triplet)))
|
if vmobject.mark_paths_closed:
|
||||||
for triplet in triplets
|
coord_strings[-1] = coord_strings[-1] + " Z"
|
||||||
]
|
result += " ".join(coord_strings)
|
||||||
end = "Z" if vmobject.mark_paths_closed else ""
|
|
||||||
result += " ".join([start] + cubics + [end])
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def display_background_colored_vmobject(self, cvmobject):
|
def display_background_colored_vmobject(self, cvmobject):
|
||||||
|
@ -307,6 +306,8 @@ class Camera(object):
|
||||||
self.pixel_array, array
|
self.pixel_array, array
|
||||||
)
|
)
|
||||||
|
|
||||||
|
## Methods for other rendering
|
||||||
|
|
||||||
def display_point_cloud(self, points, rgbas, thickness):
|
def display_point_cloud(self, points, rgbas, thickness):
|
||||||
if len(points) == 0:
|
if len(points) == 0:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue