@@ -470,7 +470,6 @@ class Graphics(Builtin):
470470 def apply_makeboxes (self , content , evaluation , options ):
471471 """MakeBoxes[%(name)s[content_, OptionsPattern[%(name)s]],
472472 StandardForm|TraditionalForm|OutputForm]"""
473-
474473 def convert (content ):
475474 head = content .get_head_name ()
476475
@@ -508,8 +507,12 @@ def convert(content):
508507 for option in options :
509508 if option not in ("System`ImageSize" ,):
510509 options [option ] = Expression ("N" , options [option ]).evaluate (evaluation )
511- box_name = "Graphics" + self .box_suffix
512- return Expression (box_name , convert (content ), * options_to_rules (options ))
510+ #box_name = "Graphics" + self.box_suffix
511+ from mathics .builtin .graphics3d import Graphics3DBox , Graphics3D
512+ if type (self ) is Graphics :
513+ return GraphicsBox (convert (content ), * options_to_rules (options ))
514+ elif type (self ) is Graphics3D :
515+ return Graphics3DBox (convert (content ), * options_to_rules (options ))
513516
514517
515518class _GraphicsElement (InstancableBuiltin ):
@@ -2598,8 +2601,8 @@ def to_svg(self):
25982601 content = self .content .boxes_to_xml (evaluation = self .graphics .evaluation )
25992602 style = create_css (font_color = self .color )
26002603 svg = (
2601- '<foreignObject x="%f" y="%f" ox="%f" oy="%f" style="%s">'
2602- " <math>%s</math></foreignObject>"
2604+ '<foreignObject x="%f" y="%f" ox="%f" oy="%f" width="100" height="100" style="%s">'
2605+ ' <math xmlns="http://www.w3.org/1998/Math/MathML" >%s</math></foreignObject>'
26032606 ) % (x , y , self .opos [0 ], self .opos [1 ], style , content )
26042607 return svg
26052608
@@ -2768,7 +2771,6 @@ class _GraphicsElements(object):
27682771 def __init__ (self , content , evaluation ):
27692772 self .evaluation = evaluation
27702773 self .elements = []
2771-
27722774 builtins = evaluation .definitions .builtin
27732775
27742776 def get_options (name ):
@@ -2936,7 +2938,10 @@ class GraphicsBox(BoxConstruct):
29362938
29372939 attributes = ("HoldAll" , "ReadProtected" )
29382940
2939- def boxes_to_text (self , leaves , ** options ):
2941+ def boxes_to_text (self , leaves = None , ** options ):
2942+ if not leaves :
2943+ leaves = self ._leaves
2944+
29402945 self ._prepare_elements (leaves , options ) # to test for Box errors
29412946 return "-Graphics-"
29422947
@@ -2992,9 +2997,7 @@ def _get_image_size(self, options, graphics_options, max_width):
29922997 def _prepare_elements (self , leaves , options , neg_y = False , max_width = None ):
29932998 if not leaves :
29942999 raise BoxConstructError
2995-
29963000 graphics_options = self .get_option_values (leaves [1 :], ** options )
2997-
29983001 background = graphics_options ["System`Background" ]
29993002 if (
30003003 isinstance (background , Symbol )
@@ -3142,7 +3145,9 @@ def get_range(min, max):
31423145
31433146 return elements , calc_dimensions
31443147
3145- def boxes_to_tex (self , leaves , ** options ):
3148+ def boxes_to_tex (self , leaves = None , ** options ):
3149+ if not leaves :
3150+ leaves = self ._leaves
31463151 elements , calc_dimensions = self ._prepare_elements (
31473152 leaves , options , max_width = 450
31483153 )
@@ -3195,7 +3200,9 @@ def boxes_to_tex(self, leaves, **options):
31953200
31963201 return tex
31973202
3198- def boxes_to_xml (self , leaves , ** options ):
3203+ def boxes_to_xml (self , leaves = None , ** options ):
3204+ if not leaves :
3205+ leaves = self ._leaves
31993206 elements , calc_dimensions = self ._prepare_elements (leaves , options , neg_y = True )
32003207
32013208 xmin , xmax , ymin , ymax , w , h , width , height = calc_dimensions ()
@@ -3229,7 +3236,7 @@ def boxes_to_xml(self, leaves, **options):
32293236 " " .join ("%f" % t for t in (xmin , ymin , w , h )),
32303237 svg ,
32313238 )
3232-
3239+ print ( "svg=" , svg_xml )
32333240 return (
32343241 '<mglyph width="%dpx" height="%dpx" src="data:image/svg+xml;base64,%s"/>'
32353242 % (
@@ -3623,7 +3630,6 @@ class _ColorObject(Builtin):
36233630
36243631 def __init__ (self , * args , ** kwargs ):
36253632 super (_ColorObject , self ).__init__ (* args , ** kwargs )
3626-
36273633 if self .text_name is None :
36283634 text_name = strip_context (self .get_name ()).lower ()
36293635 else :
@@ -3660,6 +3666,7 @@ class Black(_ColorObject):
36603666 }
36613667
36623668
3669+
36633670class White (_ColorObject ):
36643671 """
36653672 >> White
@@ -3737,6 +3744,7 @@ class Magenta(_ColorObject):
37373744 }
37383745
37393746
3747+
37403748class Yellow (_ColorObject ):
37413749 """
37423750 >> Yellow
@@ -3860,6 +3868,7 @@ class Large(Builtin):
38603868style_options = system_symbols_dict (
38613869 {
38623870 "FontColor" : _style ,
3871+ "ImageSizeMultipliers" : (lambda * x : x [1 ])
38633872 }
38643873)
38653874
0 commit comments