Beispiel #1
0
        face_color = self.face_color
        if face_color is not None:
            face_color = face_color.to_js()
        return [{
            'type': 'sphere',
            'coords': [coords.pos() for coords in self.points],
            'radius': self.radius,
            'faceColor': face_color,
        }]

    def extent(self):
        result = []
        result.extend([
            coords.add(self.radius, self.radius, self.radius).pos()[0]
            for coords in self.points])
        result.extend([
            coords.add(-self.radius, -self.radius, -self.radius).pos()[0]
            for coords in self.points])
        return result

    def _apply_boxscaling(self, boxscale):
        # TODO
        pass

GLOBALS3D = system_symbols_dict({
    'Polygon3DBox': Polygon3DBox,
    'Line3DBox': Line3DBox,
    'Point3DBox': Point3DBox,
    'Sphere3DBox': Sphere3DBox,
})
Beispiel #2
0
        return [{
            'type': 'sphere',
            'coords': [coords.pos() for coords in self.points],
            'radius': self.radius,
            'faceColor': face_color,
        }]

    def extent(self):
        result = []
        result.extend([
            coords.add(self.radius, self.radius, self.radius).pos()[0]
            for coords in self.points
        ])
        result.extend([
            coords.add(-self.radius, -self.radius, -self.radius).pos()[0]
            for coords in self.points
        ])
        return result

    def _apply_boxscaling(self, boxscale):
        # TODO
        pass


GLOBALS3D = system_symbols_dict({
    'Polygon3DBox': Polygon3DBox,
    'Line3DBox': Line3DBox,
    'Point3DBox': Point3DBox,
    'Sphere3DBox': Sphere3DBox,
})
class _GraphicsElement(InstanceableBuiltin):
    def init(self, graphics, item=None, style=None, opacity=1.0):
        if item is not None and not item.has_form(self.get_name(), None):
            raise BoxConstructError
        self.graphics = graphics
        self.style = style
        self.opacity = opacity
        self.is_completely_visible = False  # True for axis elements

    @staticmethod
    def create_as_style(klass, graphics, item):
        return klass(graphics, item)


def get_class(name):
    c = GLOBALS.get(name)
    if c is None:
        return GLOBALS3D.get(name)
    else:
        return c

    # globals() does not work with Cython, otherwise one could use something
    # like return globals().get(name)


# FIXME: GLOBALS and GLOBALS3D are a horrible names.
# These ares updated in mathics.builtin.graphics in and mathics.builtin.box.graphics3d
GLOBALS = system_symbols_dict({})
GLOBALS3D = system_symbols_dict({})
Beispiel #4
0
    def extent(self):
        result = []
        result.extend(
            [
                coords.add(self.radius, self.radius, self.radius).pos()[0]
                for coords in self.points
            ]
        )
        result.extend(
            [
                coords.add(-self.radius, -self.radius, -self.radius).pos()[0]
                for coords in self.points
            ]
        )
        return result

    def _apply_boxscaling(self, boxscale):
        # TODO
        pass


GLOBALS3D = system_symbols_dict(
    {
        "Polygon3DBox": Polygon3DBox,
        "Line3DBox": Line3DBox,
        "Point3DBox": Point3DBox,
        "Sphere3DBox": Sphere3DBox,
    }
)
Beispiel #5
0
        "RegularPolygon",
        "Sphere",
        "Style",
        "Text",
    )
)

styles = system_symbols_dict(
    {
        "RGBColor": RGBColor,
        "XYZColor": XYZColor,
        "LABColor": LABColor,
        "LCHColor": LCHColor,
        "LUVColor": LUVColor,
        "CMYKColor": CMYKColor,
        "Hue": Hue,
        "GrayLevel": GrayLevel,
        "Thickness": Thickness,
        "AbsoluteThickness": AbsoluteThickness,
        "Thick": Thick,
        "Thin": Thin,
        "PointSize": PointSize,
        "Arrowheads": Arrowheads,
    }
)

style_options = system_symbols_dict(
    {"FontColor": _style, "ImageSizeMultipliers": (lambda *x: x[1])}
)

style_heads = frozenset(styles.keys())