@@ -39,19 +39,19 @@ def init(self, image, **kwargs):
3939 def elements (self ):
4040 return self .image .elements
4141
42- def boxes_to_b64text (
42+ def to_b64text (
4343 self , elements : Tuple [BaseElement ] = None , ** options
4444 ) -> Tuple [bytes , Tuple [int , int ]]:
4545 """
4646 Produces a base64 png representation and a tuple with the size of the pillow image
4747 associated to the object.
4848 """
49- contents , size = self .boxes_to_png (elements , ** options )
49+ contents , size = self .to_png (elements , ** options )
5050 encoded = base64 .b64encode (contents )
5151 encoded = b"data:image/png;base64," + encoded
5252 return (encoded , size )
5353
54- def boxes_to_png (self , elements = None , ** options ) -> Tuple [bytes , Tuple [int , int ]]:
54+ def to_png (self , elements = None , ** options ) -> Tuple [bytes , Tuple [int , int ]]:
5555 """
5656 returns a tuple with the set of bytes with a png representation of the image
5757 and the scaled size.
@@ -97,24 +97,21 @@ def boxes_to_png(self, elements=None, **options) -> Tuple[bytes, Tuple[int, int]
9797
9898 return (contents , (scaled_width , scaled_height ))
9999
100- # FIXME "boxes_to..." should be renamed "box_to..."
101- # since there is only one box element
102-
103- def boxes_to_text (self , elements = None , ** options ) -> str :
100+ def to_text (self , elements = None , ** options ) -> str :
104101 return "-Image-"
105102
106- def boxes_to_mathml (self , elements = None , ** options ) -> str :
107- encoded , size = self .boxes_to_b64text (elements , ** options )
103+ def to_mathml (self , elements = None , ** options ) -> str :
104+ encoded , size = self .to_b64text (elements , ** options )
108105 decoded = encoded .decode ("utf8" )
109106 # see https://tools.ietf.org/html/rfc2397
110107 return f'<mglyph src="{ decoded } " width="{ size [0 ]} px" height="{ size [1 ]} px" />'
111108
112- def boxes_to_tex (self , elements = None , ** options ) -> str :
109+ def to_tex (self , elements = None , ** options ) -> str :
113110 """
114111 Store the associated image as a png file and return
115112 a LaTeX command for including it.
116113 """
117- data , size = self .boxes_to_png (elements , ** options )
114+ data , size = self .to_png (elements , ** options )
118115 res = 100 # pixels/cm
119116 width_str , height_str = (str (n / res ).strip () for n in size )
120117 head = rf"\includegraphics[width={ width_str } cm,height={ height_str } cm]"
0 commit comments