Skip to content

Commit

Permalink
update RenderControlSurface to internally represent self.color as a C…
Browse files Browse the repository at this point in the history
…olor object
  • Loading branch information
bbean23 committed Aug 12, 2024
1 parent b7addee commit b666f5a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions opencsp/common/lib/render_control/RenderControlSurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(
self,
draw_title=True,
color: str | cl.Color | None = "silver",
color_map: str | None = None,
color_map: str | matplotlib.colors.Colormap | None = None,
alpha: float = 0.25,
edgecolor='black',
linewidth=0.05,
Expand All @@ -24,10 +24,10 @@ def __init__(
----------
draw_title : bool, optional
If True then the title will be drawn on graph, default is True
color : str | None, optional
color : str | Color | None, optional
The color of the plot if not using a color map. For example
color.plot_colors.blue. By default "silver".
color_map : str | None, optional
color_map : str | Colormap None, optional
The color map of the plot to help discern different plot values. See
https://matplotlib.org/stable/gallery/color/colormap_reference.html
for common options. By default None.
Expand All @@ -52,7 +52,7 @@ def __init__(
self.draw_title = draw_title
self.alpha = alpha
self.antialiased = False if self.alpha > 0.99 else None
self.color = color
self._color = color
self.color_map = color_map
self.edgecolor = edgecolor
self.linewidth = linewidth
Expand All @@ -61,6 +61,8 @@ def __init__(
self.contour_alpha = 0.7
self.contours = {'x': False, 'y': False, 'z': False}

self._standardize_color_values()

# determine the type of contour to be drawn
if contour is None or contour == False:
self.contour = False
Expand All @@ -86,3 +88,12 @@ def __init__(
elif self.color is not None:
# TODO create a custom color map based on the color
pass

@property
def color(self) -> tuple[float, float, float, float] | None:
if self._color is not None:
return self._color.rgba()

def _standardize_color_values(self):
# convert to 'Color' class
self._color = cl.Color.convert(self._color)

0 comments on commit b666f5a

Please sign in to comment.