Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

148 even more drawing options #155

Merged
merged 20 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cdac260
fix View3d.draw_image() method and add extra options for where and ho…
bbean23 Aug 6, 2024
1db481b
reorder test_View3d tests to match the order of methods in View3d
bbean23 Aug 9, 2024
550f404
add documentation for RenderControlText, fix text rotation to be in r…
bbean23 Aug 9, 2024
9054aa4
add documentation for draw_xyz_text, fix rotation to be measured in r…
bbean23 Aug 9, 2024
7d7f8be
standardize colors in RenderControlPointSequence and in RenderControl…
bbean23 Aug 9, 2024
00de046
test the various rendering options for RenderControlPointSequence
bbean23 Aug 9, 2024
e6b0441
add method View3d.draw_heatmap_2d()
bbean23 Aug 9, 2024
0510147
documentation
bbean23 Aug 10, 2024
0e6619e
generify View3d.draw_xyz_surface()
bbean23 Aug 10, 2024
0a2dd20
add 'gradient' option to View3d.draw_pq_list()
bbean23 Aug 10, 2024
a8b69a3
typo
bbean23 Aug 12, 2024
486e5f4
standardize "color" import as "cl"
bbean23 Aug 12, 2024
59b3e6d
move color.py -> Color.py
bbean23 Aug 12, 2024
b377fa9
finish moving color.py -> Color.py
bbean23 Aug 12, 2024
7973e5d
update RenderControlSurface to internally represent self.color as a C…
bbean23 Aug 12, 2024
c799c24
fix another reference to "color" instead of "Color"
bbean23 Aug 12, 2024
616d4d7
I'm 100% sure I already fixed this >.<
bbean23 Aug 12, 2024
5e2ae7e
move test_color -> test_Color part 1
bbean23 Aug 12, 2024
4f44ed4
move test_color -> test_Color part 2
bbean23 Aug 12, 2024
4c290d0
forgot the reference image for the test
bbean23 Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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