@@ -712,10 +712,24 @@ class _CollectionWithSizes(Collection):
712
712
def get_sizes (self ):
713
713
return self ._sizes
714
714
715
+ def __unset_sizes (self ):
716
+ if len (self ._sizes ) == 0 :
717
+ return
718
+ scale = np .sqrt (self ._sizes ) * self .__dpi / 72.0
719
+ s = np .zeros ((len (self ._sizes ),3 ,3 ))
720
+ s [:, 0 , 0 ] = scale
721
+ s [:, 1 , 1 ] = scale
722
+ s [:, 2 , 2 ] = 1.0
723
+ for i in xrange (self ._transforms .shape [0 ]):
724
+ isc = np .linalg .inv (s [i % len (self ._sizes ),:,:])
725
+ self ._transforms [i ,:,:] = np .dot (isc , self ._transforms [i ,:,:])
726
+
715
727
def set_sizes (self , sizes , dpi = 72.0 ):
728
+ # unset the size on transforms
729
+ self .__unset_sizes ()
730
+ self .__dpi = dpi
716
731
if sizes is None :
717
732
self ._sizes = np .array ([])
718
- self ._transforms = np .empty ((0 , 3 , 3 ))
719
733
else :
720
734
self ._sizes = np .asarray (sizes )
721
735
scale = np .sqrt (self ._sizes ) * dpi / 72.0
@@ -744,10 +758,26 @@ class _CollectionWithAngles(Collection):
744
758
def get_angles (self ):
745
759
return self ._angles
746
760
761
+ def __unset_angles (self ):
762
+ if len (self ._angles ) == 0 :
763
+ return
764
+ rot = np .deg2rad (- self ._angles )
765
+ rot_c = np .cos (rot )
766
+ rot_s = np .sin (rot )
767
+ r = np .zeros ((len (self ._angles ), 3 , 3 ))
768
+ r [:, 0 , 0 ] = rot_c
769
+ r [:, 0 , 1 ] = - rot_s
770
+ r [:, 1 , 1 ] = rot_c
771
+ r [:, 1 , 0 ] = rot_s
772
+ r [:, 2 , 2 ] = 1.0
773
+ for i in xrange (self ._transforms .shape [0 ]):
774
+ irt = np .linalg .inv (r [i % len (self ._angles ),:,:])
775
+ self ._transforms [i ,:,:] = np .dot (irt , self ._transforms [i ,:,:])
776
+
747
777
def set_angles (self , angles ):
778
+ self .__unset_angles ()
748
779
if angles is None :
749
780
self ._angles = np .array ([])
750
- self ._transforms = np .empty ((0 , 3 , 3 ))
751
781
else :
752
782
self ._angles = np .asarray (angles )
753
783
rot = np .deg2rad (- self ._angles )
0 commit comments