@@ -104,8 +104,14 @@ def generate_table(objectsDB: dict, tag: str, brMax: bool, brGeom: bool, srgb: b
104104
105105 # Creating of background of colored squircles
106106 arr = np .zeros ((h , w , 3 ))
107- squircle = higher_dim (generate_squircle (r_square , rounding_radius ), times = 3 , axis = 2 )
108- squircle_contour = higher_dim (generate_squircle_contour (r_square , rounding_radius , 1 ), times = 3 , axis = 2 ) * 0.25
107+ shapes = (
108+ higher_dim (generate_squircle_contour (r_square + 1 , rounding_radius , 2 ), times = 3 , axis = 2 ),
109+ higher_dim (generate_squircle (r_square , rounding_radius ), times = 3 , axis = 2 )
110+ )
111+ text_colors = (
112+ (0 , 0 , 0 ),
113+ (255 , 255 , 255 )
114+ )
109115 is_white_text = np .empty (l , dtype = 'bool' )
110116 object_notes = []
111117
@@ -114,30 +120,46 @@ def generate_table(objectsDB: dict, tag: str, brMax: bool, brGeom: bool, srgb: b
114120 # Spectral data import and processing
115121 body = database_parser (obj_name , objectsDB [obj_name ])
116122 spectrum , estimated = body .get_spectrum ('geometric' if brGeom else 'spherical' )
123+
124+ # Color calculation
125+ maximize_br = brMax or isinstance (body , NonReflectiveBody )
126+ color = ColorPoint .from_spectral_data (spectrum , maximize_br , srgb )
127+ if gamma :
128+ color = color .gamma_corrected ()
117129
118- # Setting of notes
130+ # Setting of notes and shape
119131 if not brMax and isinstance (body , NonReflectiveBody ):
120- object_notes .append (tr .table_no_albedo [lang ])
132+ if 'star' in body .tags :
133+ is_filled = True
134+ object_notes .append (None )
135+ else :
136+ is_filled = False
137+ object_notes .append (tr .table_no_albedo [lang ])
121138 else :
139+ is_filled = True
122140 if estimated :
123141 object_notes .append (tr .table_estimated [lang ])
124142 else :
125143 object_notes .append (None )
126-
127- # Color calculation
128- maximize_br = brMax or isinstance (body , NonReflectiveBody )
129- color = ColorPoint .from_spectral_data (spectrum , maximize_br , srgb )
130- if gamma :
131- color = color .gamma_corrected ()
132- is_white_text [n ] = color .grayscale () > 0.5
133144
134- # Rounded square. For just a square, use `object_template = color.br`
135- object_template = color .br * squircle if np .any (color .br ) else squircle_contour
145+ # Setting object and text colors
146+ if np .any (color .br ):
147+ if is_filled :
148+ object_color = color .br
149+ is_white_text [n ] = color .grayscale () < 0.5
150+ else :
151+ object_color = color .br / color .grayscale () / 3
152+ is_white_text [n ] = True
153+ else :
154+ # error handling
155+ object_color = 1 / 3
156+ is_white_text [n ] = True
136157
137158 # Placing object template into the image template
138159 center_x = centers_x [n ]
139160 center_y = centers_y [n ]
140- arr [center_y - r_square :center_y + r_square , center_x - r_square :center_x + r_square , :] = object_template
161+ r_sq = r_square if is_filled else r_square + 1
162+ arr [center_y - r_sq :center_y + r_sq , center_x - r_sq :center_x + r_sq , :] = shapes [is_filled ] * object_color
141163
142164 # Creating of image template
143165 img = Image .fromarray (np .clip (np .round (arr * 255 ), 0 , 255 ).astype ('int8' ), 'RGB' )
@@ -168,7 +190,7 @@ def generate_table(objectsDB: dict, tag: str, brMax: bool, brGeom: bool, srgb: b
168190 center_x = centers_x [n ]
169191 center_y = centers_y [n ]
170192
171- text_color = ( 0 , 0 , 0 ) if is_white_text [n ] else ( 255 , 255 , 255 )
193+ text_color = text_colors [ is_white_text [n ]]
172194
173195 if (object_note := object_notes [n ]) is not None :
174196 draw .text ((center_x + r_active , center_y + r_active ), object_note , text_color , small_font , anchor = 'rs' , align = 'right' )
0 commit comments