# Path: magical/style.py
# COLOURS_RGB = {
#     # I'm using Berkeley-branded versions of RGBY from
#     # https://brand.berkeley.edu/colors/ (lightened).
#     'blue': lighten_rgb(rgb(0x3B, 0x7E, 0xA1), 1.7),  # founder's rock
#     'yellow': lighten_rgb(rgb(0xFD, 0xB5, 0x15), 1.7),  # california gold
#     'red': lighten_rgb(rgb(0xEE, 0x1F, 0x60), 1.7),  # rose garden
#     'green': lighten_rgb(rgb(0x85, 0x94, 0x38), 1.7),  # soybean
#     'grey': rgb(162, 163, 175),  # cool grey (not sure which one)
#     'brown': rgb(224, 171, 118),  # buff
# }
# 
# GOAL_LINE_THICKNESS = 0.01
# 
# ROBOT_LINE_THICKNESS = 0.01
# 
# SHAPE_LINE_THICKNESS = 0.015
# 
# def darken_rgb(rgb):
#     """Produce a darker version of a base colour."""
#     h, l, s = colorsys.rgb_to_hls(*rgb)
#     hls_new = (h, max(0, l * 0.9), s)
#     return colorsys.hls_to_rgb(*hls_new)
# 
# def lighten_rgb(rgb, times=1):
#     """Produce a lighter version of a given base colour."""
#     h, l, s = colorsys.rgb_to_hls(*rgb)
#     mult = 1.4**times
#     hls_new = (h, 1 - (1 - l) / mult, s)
#     return colorsys.hls_to_rgb(*hls_new)


import abc
import enum
import math
import weakref
import numpy as np
import pymunk as pm
import pymunk.autogeometry as autogeom
import magical.geom as gtools
import magical.gym_render as r
from magical.style import (
    COLOURS_RGB, GOAL_LINE_THICKNESS, ROBOT_LINE_THICKNESS,
    SHAPE_LINE_THICKNESS, darken_rgb, lighten_rgb)
                      colour_name=self.colour_name)
        return type(self), kwargs

    def setup(self, *args, **kwargs):
        super().setup(*args, **kwargs)

        # the space only needs a sensor body
        self.goal_body = pm.Body(body_type=pm.Body.STATIC)
        self.goal_shape = pm.Poly.create_box(self.goal_body, (self.w, self.h))
        self.goal_shape.sensor = True
        self.goal_body.position = (self.x + self.w / 2, self.y - self.h / 2)
        self.add_to_space(self.goal_body, self.goal_shape)

        # Making visual display: region should consist of very lightly shaded
        # rectangle, surrounded by darker stippled border. Ideally corners on
        # the rectangle should be rounded.
        self.rect_xform = r.Transform()
        self.rect_xform.set_translation(*self.goal_body.position)
        self.rect_xform.set_rotation(self.goal_body.angle)

        inner_colour = lighten_rgb(self.base_colour, times=2)
        inner_rect = r.make_rect(width=self.w, height=self.h, filled=True)
        inner_rect.set_color(*inner_colour)
        inner_rect.add_attr(self.rect_xform)
        self.viewer.add_geom(inner_rect)

        outer_colour = self.base_colour
        outer_rect = r.make_rect(width=self.w, height=self.h, filled=False)
        outer_rect.set_color(*outer_colour)
        outer_rect.add_attr(r.LineStyle(0x00FF))

# Path: magical/style.py
# COLOURS_RGB = {
#     # I'm using Berkeley-branded versions of RGBY from
#     # https://brand.berkeley.edu/colors/ (lightened).
#     'blue': lighten_rgb(rgb(0x3B, 0x7E, 0xA1), 1.7),  # founder's rock
#     'yellow': lighten_rgb(rgb(0xFD, 0xB5, 0x15), 1.7),  # california gold
#     'red': lighten_rgb(rgb(0xEE, 0x1F, 0x60), 1.7),  # rose garden
#     'green': lighten_rgb(rgb(0x85, 0x94, 0x38), 1.7),  # soybean
#     'grey': rgb(162, 163, 175),  # cool grey (not sure which one)
#     'brown': rgb(224, 171, 118),  # buff
# }
# 
# GOAL_LINE_THICKNESS = 0.01
# 
# ROBOT_LINE_THICKNESS = 0.01
# 
# SHAPE_LINE_THICKNESS = 0.015
# 
# def darken_rgb(rgb):
#     """Produce a darker version of a base colour."""
#     h, l, s = colorsys.rgb_to_hls(*rgb)
#     hls_new = (h, max(0, l * 0.9), s)
#     return colorsys.hls_to_rgb(*hls_new)
# 
# def lighten_rgb(rgb, times=1):
#     """Produce a lighter version of a given base colour."""
#     h, l, s = colorsys.rgb_to_hls(*rgb)
#     mult = 1.4**times
#     hls_new = (h, 1 - (1 - l) / mult, s)
#     return colorsys.hls_to_rgb(*hls_new)


# Path: magical/entities.py
import abc
import enum
import math
import weakref
import numpy as np
import pymunk as pm
import pymunk.autogeometry as autogeom
import magical.geom as gtools
import magical.gym_render as r
from magical.style import (
    COLOURS_RGB, GOAL_LINE_THICKNESS, ROBOT_LINE_THICKNESS,
    SHAPE_LINE_THICKNESS, darken_rgb, lighten_rgb)

                      colour_name=self.colour_name)
        return type(self), kwargs

    def setup(self, *args, **kwargs):
        super().setup(*args, **kwargs)

        # the space only needs a sensor body
        self.goal_body = pm.Body(body_type=pm.Body.STATIC)
        self.goal_shape = pm.Poly.create_box(self.goal_body, (self.w, self.h))
        self.goal_shape.sensor = True
        self.goal_body.position = (self.x + self.w / 2, self.y - self.h / 2)
        self.add_to_space(self.goal_body, self.goal_shape)

        # Making visual display: region should consist of very lightly shaded
        # rectangle, surrounded by darker stippled border. Ideally corners on
        # the rectangle should be rounded.
        self.rect_xform = r.Transform()
        self.rect_xform.set_translation(*self.goal_body.position)
        self.rect_xform.set_rotation(self.goal_body.angle)

        inner_colour = lighten_rgb(self.base_colour, times=2)
        inner_rect = r.make_rect(width=self.w, height=self.h, filled=True)
        inner_rect.set_color(*inner_colour)
        inner_rect.add_attr(self.rect_xform)
        self.viewer.add_geom(inner_rect)

        outer_colour = self.base_colour
        outer_rect = r.make_rect(width=self.w, height=self.h, filled=False)
        outer_rect.set_color(*outer_colour)
        outer_rect.add_attr(r.LineStyle(0x00FF))

        outer_rect.set_linewidth(250 * GOAL_LINE_THICKNESS)