Skip to content

Commit

Permalink
Merge pull request #155 from bbean23/148-even-more-drawing-options
Browse files Browse the repository at this point in the history
148 even more drawing options
  • Loading branch information
bbean23 authored Sep 6, 2024
2 parents 293e0db + 4c290d0 commit 772ecae
Show file tree
Hide file tree
Showing 21 changed files with 1,095 additions and 483 deletions.
48 changes: 23 additions & 25 deletions example/targetcolor/example_TargetColor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import matplotlib
import numpy as np

import opencsp.common.lib.render.color as Color # ?? SCAFFOLDING RCB - FIX FILENAME TO CAPITALIZED
import opencsp.common.lib.render.Color as cl # ?? SCAFFOLDING RCB - FIX FILENAME TO CAPITALIZED
import opencsp.common.lib.target.TargetColor as tc
import opencsp.common.lib.target.target_color_2d_rgb as tc2r
import opencsp.common.lib.target.target_color_convert as tcc
Expand Down Expand Up @@ -76,7 +76,7 @@ def setup_class(

# ?? SCAFFOLDING RCB -- ADD COLOR_BAR TYPE TIP BELOW
def execute_example_linear_color_bar(
self, color_below_min: Color, color_bar, color_bar_name: str, color_above_max: Color, generate_all: bool
self, color_below_min: cl.Color, color_bar, color_bar_name: str, color_above_max: cl.Color, generate_all: bool
) -> None:
if generate_all:
# Linear color bar in x, discrete.
Expand Down Expand Up @@ -139,7 +139,7 @@ def execute_example_linear_color_bar(

# ?? SCAFFOLDING RCB -- ADD COLOR_BAR TYPE TIP BELOW
def execute_example_polar_color_bar(
self, color_below_min: Color, color_bar, color_bar_name: str, color_above_max: Color
self, color_below_min: cl.Color, color_bar, color_bar_name: str, color_above_max: cl.Color
) -> None:
# Default.
target = tc.construct_target_polar_color_bar(self.image_width, self.image_height, self.dpm)
Expand Down Expand Up @@ -188,28 +188,26 @@ def execute_example_extend_target(self) -> None:
target = tc.construct_target_blue_under_red_cross_green(self.image_width, self.image_height, self.dpm)
# Extend left.
left_pixels = 10 # Pixels
extended_target_left = tc.extend_target_left(target, left_pixels, Color.white())
extended_target_left = tc.extend_target_left(target, left_pixels, cl.white())
# self.save_and_check_image(extended_target_left.image, self.dpm, extended_target_left.description_inch(), '.png')
# Extend right.
right_pixels = 20 # Pixels
extended_target_left_right = tc.extend_target_right(extended_target_left, right_pixels, Color.grey())
extended_target_left_right = tc.extend_target_right(extended_target_left, right_pixels, cl.grey())
# self.save_and_check_image(extended_target_left_right.image, self.dpm, extended_target_left_right.description_inch(), '.png')
# Extend top.
top_pixels = 30 # Pixels
extended_target_left_right_top = tc.extend_target_top(
extended_target_left_right, top_pixels, Color.light_grey()
)
extended_target_left_right_top = tc.extend_target_top(extended_target_left_right, top_pixels, cl.light_grey())
# self.save_and_check_image(extended_target_left_right_top.image, self.dpm, extended_target_left_right_top.description_inch(), '.png')
# Extend bottom.
bottom_pixels = 40 # Pixels
extended_target_left_right_top_bottom = tc.extend_target_bottom(
extended_target_left_right_top, bottom_pixels, Color.dark_grey()
extended_target_left_right_top, bottom_pixels, cl.dark_grey()
)
# self.save_and_check_image(extended_target_left_right_top_bottom.image, self.dpm, extended_target_left_right_top_bottom.description_inch(), '.png')
# Border all around.
border_pixels = 5 # Pixels
extended_target_left_right_top_bottom_border = tc.extend_target_all(
extended_target_left_right_top_bottom, border_pixels, Color.magenta()
extended_target_left_right_top_bottom, border_pixels, cl.magenta()
)
self.save_and_check_image(
extended_target_left_right_top_bottom_border.image,
Expand Down Expand Up @@ -241,7 +239,7 @@ def execute_example_splice_targets_above_below(self) -> None:
# Combine.
# ?? SCAFFOLDING RCB -- SHOULD THIS BE IN INCHES?
gap = 0 # Pixels # ?? SCAFFOLDING RCB -- SHOULD THIS BE IN INCHES?
spliced_target = tc.splice_targets_above_below(target_1, target_2, gap, Color.white())
spliced_target = tc.splice_targets_above_below(target_1, target_2, gap, cl.white())
self.save_and_check_image(spliced_target.image, self.dpm, spliced_target.description_inch(), '.png')

def execute_example_cascade_target_A(self) -> None:
Expand Down Expand Up @@ -278,15 +276,15 @@ def execute_example_cascade_target_A(self) -> None:

# Linear color bar definition.
# Main: Color bar corrected for Nikon D3300 response.
color_below_min = Color.black() # Black below bottom of color bar.
color_below_min = cl.black() # Black below bottom of color bar.
color_bar = tcc.nikon_D3300_monitor_equal_step_color_bar()
color_bar_name = 'D3300_monitor' # ?? SCAFFOLDING RCB -- THIS SHOULD BE A CLASS MEMBER
color_above_max = Color.white() # White background for "saturated data."
color_above_max = cl.white() # White background for "saturated data."
# Closed color wheel linear color bar.
ref_color_below_min = Color.black() # Black below bottom of color bar.
ref_color_below_min = cl.black() # Black below bottom of color bar.
ref_color_bar = tcc.O_color_bar()
ref_color_bar_name = 'O' # ?? SCAFFOLDING RCB -- THIS SHOULD BE A CLASS MEMBER
ref_color_above_max = Color.white() # White background for "saturated data."
ref_color_above_max = cl.white() # White background for "saturated data."

cascade_target = tc.construct_linear_color_bar_cascade( # Dimensions.
color_bar_width,
Expand Down Expand Up @@ -360,15 +358,15 @@ def execute_example_cascade_target_A(self) -> None:
gap_between_bars * composite_dpm
), # Pixels # ?? SCAFFOLDING RCB -- SHOULD THIS BE IN INCHES?
ref_gap_pix=round(ref_gap * composite_dpm), # Pixels # ?? SCAFFOLDING RCB -- SHOULD THIS BE IN INCHES?
gap_color=Color.white(),
gap_color=cl.white(),
)

# Fiducial marks.
n_ticks_x = 13 # No units. Number of tick marks to draw along top/bottom horizontal target edges.
n_ticks_y = 25 # No units. Number of tick marks to draw along left/right vertical target edges.
tick_length = 0.010 # Meters. Length to draw edge tick marks.
tick_width_pix = 3 # Pixels. Width to draw edge tick marks; should be odd number.
tick_color: Color = Color.black() # Color. Color of edge tick marks.
tick_color: cl.Color = cl.black() # Color. Color of edge tick marks.
cascade_target.set_ticks_along_top_and_bottom_edges(n_ticks_x, tick_length, tick_width_pix, tick_color)
cascade_target.set_ticks_along_left_and_right_edges(n_ticks_y, tick_length, tick_width_pix, tick_color)

Expand All @@ -380,20 +378,20 @@ def example_matlab(self) -> None:
# Initialize test.
self.start_test()
# MATLAB color bar.
color_below_min = Color.black() # Black below bottom of color bar.
color_below_min = cl.black() # Black below bottom of color bar.
color_bar = tcc.matlab_color_bar()
color_bar_name = 'matlab'
color_above_max = Color.white() # White background for "saturated data."
color_above_max = cl.white() # White background for "saturated data."
self.execute_example_linear_color_bar(color_below_min, color_bar, color_bar_name, color_above_max, False)

def example_matlab_equal_angle(self) -> None:
# Initialize test.
self.start_test()
# Normalized MATLAB color bar.
color_below_min = Color.black() # Black below bottom of color bar.
color_below_min = cl.black() # Black below bottom of color bar.
color_bar = tcc.normalize_color_bar_to_equal_angles(tcc.matlab_color_bar())
color_bar_name = 'matlab_equal_angle'
color_above_max = Color.white() # White background for "saturated data."
color_above_max = cl.white() # White background for "saturated data."
self.execute_example_linear_color_bar(color_below_min, color_bar, color_bar_name, color_above_max, False)

# # Closed corner tour color bar.
Expand All @@ -410,10 +408,10 @@ def example_corner_tour_closed_equal_angle(self) -> None:
# Initialize test.
self.start_test()
# Normalized closed corner tour color bar.
color_below_min = Color.black() # Black below bottom of color bar.
color_below_min = cl.black() # Black below bottom of color bar.
color_bar = tcc.normalize_color_bar_to_equal_angles(tcc.corner_tour_closed_color_bar())
color_bar_name = 'corner_tour_closed_equal_angle'
color_above_max = Color.white() # White background for "saturated data."
color_above_max = cl.white() # White background for "saturated data."
self.execute_example_linear_color_bar(color_below_min, color_bar, color_bar_name, color_above_max, True)

# # Closed color wheel linear color bar.
Expand All @@ -427,10 +425,10 @@ def example_polar_color_bar(self) -> None:
# Initialize test.
self.start_test()
# Closed color wheel polar image.
color_below_min = Color.black() # Black below bottom of color bar.
color_below_min = cl.black() # Black below bottom of color bar.
color_bar = tcc.O_color_bar()
color_bar_name = 'O' # ?? SCAFFOLDING RCB -- THIS SHOULD BE A CLASS MEMBER
color_above_max = Color.white() # White background for "saturated data."
color_above_max = cl.white() # White background for "saturated data."
self.execute_example_polar_color_bar(color_below_min, color_bar, color_bar_name, color_above_max)

def example_blue_under_red_cross_green(self) -> None:
Expand Down
Loading

0 comments on commit 772ecae

Please sign in to comment.