Skip to content

Commit 0587675

Browse files
committed
Pull out more from graphics!
Refactor all of the color stuff into drawing/colors.py and color_internals.py Note drawing/color_internals.py used to be somewhat vague name drawing/colors.py. But really it just had internal color routines. drawing/colors.py was selected because that's what the Section name is in WL https://reference.wolfram.com/language/guide/Colors.html and the classes in there all into what's described there. Down the line it would be nice to separate better externally visable classes from all the implementaiton code that is not visiable, but that's too big a lift for now. Note: this started out as just an effort to document some of the builtins that had no documentaiton. And a little of that has been done too.
1 parent 6517617 commit 0587675

File tree

12 files changed

+1119
-1058
lines changed

12 files changed

+1119
-1058
lines changed

mathics/builtin/box/graphics.py

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@
1111
BoxConstructError,
1212
)
1313

14+
from mathics.builtin.drawing.colors import _Color, ColorError, RGBColor
15+
from mathics.builtin.drawing.graphics_internals import _GraphicsElement, GLOBALS
16+
1417
from mathics.builtin.graphics import (
1518
Arrowheads,
16-
ColorError,
1719
Coords,
1820
DEFAULT_POINT_FACTOR,
19-
GLOBALS,
2021
Graphics,
2122
GraphicsElements,
2223
PointSize,
23-
RGBColor,
2424
_BezierCurve,
25-
_Color,
26-
_GraphicsElement,
2725
_Line,
2826
_Polyline,
2927
_data_and_options,
@@ -1176,20 +1174,19 @@ def vertices():
11761174
super(RegularPolygonBox, self).init(graphics, style, new_item)
11771175

11781176

1179-
GLOBALS_GRAPHICS = system_symbols_dict(
1177+
# FIXME: GLOBALS is a horrible name.
1178+
GLOBALS.update(
11801179
{
1181-
"RectangleBox": RectangleBox,
1182-
"DiskBox": DiskBox,
1183-
"LineBox": LineBox,
1184-
"BezierCurveBox": BezierCurveBox,
1185-
"FilledCurveBox": FilledCurveBox,
1186-
"ArrowBox": ArrowBox,
1187-
"CircleBox": CircleBox,
1188-
"PolygonBox": PolygonBox,
1189-
"RegularPolygonBox": RegularPolygonBox,
1190-
"PointBox": PointBox,
1191-
"InsetBox": InsetBox,
1180+
"System`RectangleBox": RectangleBox,
1181+
"System`DiskBox": DiskBox,
1182+
"System`LineBox": LineBox,
1183+
"System`BezierCurveBox": BezierCurveBox,
1184+
"System`FilledCurveBox": FilledCurveBox,
1185+
"System`ArrowBox": ArrowBox,
1186+
"System`CircleBox": CircleBox,
1187+
"System`PolygonBox": PolygonBox,
1188+
"System`RegularPolygonBox": RegularPolygonBox,
1189+
"System`PointBox": PointBox,
1190+
"System`InsetBox": InsetBox,
11921191
}
11931192
)
1194-
1195-
GLOBALS.update(GLOBALS_GRAPHICS)

mathics/builtin/box/graphics3d.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,16 @@
1010
from mathics.builtin.base import BoxConstructError
1111
from mathics.builtin.box.graphics import GraphicsBox, LineBox, PointBox, PolygonBox
1212

13+
from mathics.builtin.drawing.colors import _Color, RGBColor
14+
from mathics.builtin.drawing.graphics_internals import GLOBALS3D
1315
from mathics.builtin.drawing.graphics3d import (
1416
_Graphics3DElement,
1517
Coords3D,
1618
Graphics3DElements,
1719
)
1820

19-
from mathics.core.expression import (
20-
Symbol,
21-
system_symbols_dict,
22-
)
23-
24-
from mathics.builtin.graphics import (
25-
RGBColor,
26-
_Color,
27-
get_class,
28-
)
29-
21+
from mathics.builtin.drawing.graphics_internals import get_class
22+
from mathics.core.expression import Symbol
3023
from mathics.core.formatter import lookup_method
3124
from mathics.format.asy_fns import asy_create_pens, asy_number
3225

@@ -809,11 +802,12 @@ def _apply_boxscaling(self, boxscale):
809802
pass
810803

811804

812-
GLOBALS3D = system_symbols_dict(
805+
# FIXME: GLOBALS3D is a horrible name.
806+
GLOBALS3D.update(
813807
{
814-
"Polygon3DBox": Polygon3DBox,
815-
"Line3DBox": Line3DBox,
816-
"Point3DBox": Point3DBox,
817-
"Sphere3DBox": Sphere3DBox,
808+
"System`Polygon3DBox": Polygon3DBox,
809+
"System`Line3DBox": Line3DBox,
810+
"System`Point3DBox": Point3DBox,
811+
"System`Sphere3DBox": Sphere3DBox,
818812
}
819813
)

0 commit comments

Comments
 (0)