# 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)
        for g in geoms_inner:
            g.set_color(*self.colour)
        for g in geoms_outer:
            g.set_color(*darken_rgb(self.colour))
        self.shape_xform = r.Transform()
        shape_compound = r.Compound(geoms_outer + geoms_inner)
        shape_compound.add_attr(self.shape_xform)
        self.viewer.add_geom(shape_compound)

    def pre_draw(self):
        self.shape_xform.set_translation(*self.shape_body.position)
        self.shape_xform.set_rotation(self.shape_body.angle)


# #############################################################################
# Sensor region for pushing shapes into.
# #############################################################################


class GoalRegion(Entity):
    """A goal region that the robot should push certain shapes into. It's up to
    the caller to figure out exactly which shapes & call methods for collision
    checking/scoring."""
    def __init__(self, x, y, h, w, colour_name):
        self.x = x
        self.y = y
        assert h > 0, w > 0
        self.h = h
        self.w = w
        self.colour_name = colour_name

# 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)

        for g in geoms_inner:
            g.set_color(*self.colour)
        for g in geoms_outer:
            g.set_color(*darken_rgb(self.colour))
        self.shape_xform = r.Transform()
        shape_compound = r.Compound(geoms_outer + geoms_inner)
        shape_compound.add_attr(self.shape_xform)
        self.viewer.add_geom(shape_compound)

    def pre_draw(self):
        self.shape_xform.set_translation(*self.shape_body.position)
        self.shape_xform.set_rotation(self.shape_body.angle)


# #############################################################################
# Sensor region for pushing shapes into.
# #############################################################################


class GoalRegion(Entity):
    """A goal region that the robot should push certain shapes into. It's up to
    the caller to figure out exactly which shapes & call methods for collision
    checking/scoring."""
    def __init__(self, x, y, h, w, colour_name):
        self.x = x
        self.y = y
        assert h > 0, w > 0
        self.h = h
        self.w = w
        self.colour_name = colour_name

        self.base_colour = COLOURS_RGB[colour_name]