@@ -237,121 +237,115 @@ pub fn window_main(renderer: Arc<Mutex<FractalRenderer>>) -> impl Widget<Fractal
237237 data. palette_source . clone ( )
238238 } ) . align_right ( ) . expand_width ( ) , 0.5 ) )
239239 . with_spacer ( 4.0 )
240- . with_child ( Flex :: column ( )
241- . with_child ( Image :: new ( {
242- let buffer = renderer. lock ( ) . data_export . clone ( ) ;
243- let step = ( buffer. lock ( ) . palette_interpolated_buffer . len ( ) / 500 ) . max ( 1 ) ;
244- let raw_buffer = buffer. lock ( ) . palette_interpolated_buffer . iter ( ) . step_by ( step) . map ( |value| {
245- let ( r, g, b, _) = value. rgba_u8 ( ) ;
246- vec ! [ r, g, b]
247- } ) . flatten ( ) . collect :: < Vec < u8 > > ( ) ;
240+ . with_child ( Image :: new ( {
241+ let buffer = renderer. lock ( ) . data_export . clone ( ) ;
242+ let step = ( buffer. lock ( ) . palette_interpolated_buffer . len ( ) / 500 ) . max ( 1 ) ;
243+ let raw_buffer = buffer. lock ( ) . palette_interpolated_buffer . iter ( ) . step_by ( step) . map ( |value| {
244+ let ( r, g, b, _) = value. rgba_u8 ( ) ;
245+ vec ! [ r, g, b]
246+ } ) . flatten ( ) . collect :: < Vec < u8 > > ( ) ;
248247
249- let width = raw_buffer. len ( ) / 3 ;
250- ImageBuf :: from_raw ( raw_buffer, ImageFormat :: Rgb , width, 1 )
251- } ) . interpolation_mode ( InterpolationMode :: Bilinear )
252- . fill_mode ( FillStrat :: Fill )
253- . controller ( PaletteUpdateController )
254- . fix_height ( 24.0 )
255- . expand_width ( ) )
256- . with_spacer ( 4.0 )
257- . with_child ( create_label_textbox_row ( "Span:" , 160.0 )
258- . lens ( FractalData :: palette_iteration_span) )
259- . with_spacer ( 4.0 )
260- . with_child ( Flex :: row ( )
261- . with_child ( Label :: new ( "Offset:" ) . fix_width ( 100.0 ) )
262- . with_flex_child ( Slider :: new ( )
263- . with_range ( 0.0 , 1.0 )
264- . expand_width ( )
265- . lens ( FractalData :: palette_offset) , 1.0 )
266- . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
267- format ! ( "{:>.3}" , * data)
268- } ) . lens ( FractalData :: palette_offset) ) ) )
269- . with_spacer ( 4.0 )
270- . with_child ( create_checkbox_row ( "Cyclic palette" ) . lens ( FractalData :: palette_cyclic) )
271- . with_spacer ( 4.0 )
272- . with_child ( create_checkbox_row ( "Distance color" ) . lens ( FractalData :: distance_color) )
273- . with_spacer ( 4.0 )
274- . with_child ( create_label_textbox_row ( "Stripe Scale:" , 160.0 )
275- . lens ( FractalData :: stripe_scale) )
276- . with_spacer ( 4.0 )
277- . with_child ( create_label_textbox_row ( "Distance Transition:" , 160.0 )
278- . lens ( FractalData :: distance_transition) )
279- . with_spacer ( 4.0 )
280- . with_child ( create_checkbox_row ( "Lighting" ) . lens ( FractalData :: lighting) )
281- . with_spacer ( 4.0 )
282- . with_child ( Flex :: row ( )
283- . with_child ( Label :: new ( "Direction:" ) . fix_width ( 100.0 ) )
284- . with_flex_child ( Slider :: new ( )
285- . with_range ( 0.0 , 180.0 )
286- . expand_width ( )
287- . lens ( FractalData :: lighting_direction. map ( |val| * val / 2.0 , |new, val| * new = 2.0 * val. round ( ) ) ) , 1.0 )
288- . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
289- format ! ( "{:>3.0}°" , * data)
290- } ) . lens ( FractalData :: lighting_direction) ) )
291- . with_spacer ( 4.0 )
292- . with_child ( Flex :: row ( )
293- . with_child ( Label :: new ( "Azimuth:" ) . fix_width ( 100.0 ) )
294- . with_flex_child ( Slider :: new ( )
295- . with_range ( 0.0 , 90.0 )
296- . expand_width ( )
297- . lens ( FractalData :: lighting_azimuth. map ( |val| * val, |new, val| * new = val. round ( ) ) ) , 1.0 )
298- . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
299- format ! ( "{:>3.0}°" , * data)
300- } ) . lens ( FractalData :: lighting_azimuth) ) )
301- . with_spacer ( 4.0 )
302- . with_child ( Flex :: row ( )
303- . with_child ( Label :: new ( "Opacity:" ) . fix_width ( 100.0 ) )
304- . with_flex_child ( Slider :: new ( )
305- . with_range ( 0.0 , 1.0 )
306- . expand_width ( )
307- . lens ( FractalData :: lighting_opacity) , 1.0 )
308- . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
309- format ! ( "{:>4.1}%" , 100.0 * * data)
310- } ) . lens ( FractalData :: lighting_opacity) ) )
311- . with_spacer ( 4.0 )
312- . with_child ( Flex :: row ( )
313- . with_child ( Label :: new ( "Ambient:" ) . fix_width ( 100.0 ) )
314- . with_flex_child ( Slider :: new ( )
315- . with_range ( 0.0 , 1.0 )
316- . expand_width ( )
317- . lens ( FractalData :: lighting_ambient) , 1.0 )
318- . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
319- format ! ( "{:>4.1}%" , 100.0 * * data)
320- } ) . lens ( FractalData :: lighting_ambient) ) )
321- . with_spacer ( 4.0 )
322- . with_child ( Flex :: row ( )
323- . with_child ( Label :: new ( "Diffuse:" ) . fix_width ( 100.0 ) )
324- . with_flex_child ( Slider :: new ( )
325- . with_range ( 0.0 , 1.0 )
326- . expand_width ( )
327- . lens ( FractalData :: lighting_diffuse) , 1.0 )
328- . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
329- format ! ( "{:>4.1}%" , 100.0 * * data)
330- } ) . lens ( FractalData :: lighting_diffuse) ) )
331- . with_spacer ( 4.0 )
332- . with_child ( Flex :: row ( )
333- . with_child ( Label :: new ( "Specular:" ) . fix_width ( 100.0 ) )
334- . with_flex_child ( Slider :: new ( )
335- . with_range ( 0.0 , 1.0 )
336- . expand_width ( )
337- . lens ( FractalData :: lighting_specular) , 1.0 )
338- . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
339- format ! ( "{:>4.1}%" , 100.0 * * data)
340- } ) . lens ( FractalData :: lighting_specular) ) )
341- . with_spacer ( 4.0 )
342- . with_child ( Flex :: row ( )
343- . with_child ( Label :: new ( "Shininess:" ) . fix_width ( 100.0 ) )
344- . with_flex_child ( Slider :: new ( )
345- . with_range ( 0.0 , 50.0 )
346- . expand_width ( )
347- . lens ( FractalData :: lighting_shininess. map ( |val| * val as f64 , |new, val| * new = val as i64 ) ) , 1.0 )
348- . with_child ( Label :: < i64 > :: new ( |data : & i64 , _env : & _ | {
349- format ! ( "{:>4}" , * data)
350- } ) . lens ( FractalData :: lighting_shininess) ) )
351- . with_spacer ( 4.0 )
352- . with_child ( Button :: new ( "SET" ) . on_click ( |ctx, _data : & mut FractalData , _env| {
353- ctx. submit_command ( SET_OFFSET_SPAN ) ;
354- } ) . expand_width ( ) . fix_height ( 36.0 ) ) ;
248+ let width = raw_buffer. len ( ) / 3 ;
249+ ImageBuf :: from_raw ( raw_buffer, ImageFormat :: Rgb , width, 1 )
250+ } ) . interpolation_mode ( InterpolationMode :: Bilinear )
251+ . fill_mode ( FillStrat :: Fill )
252+ . controller ( PaletteUpdateController )
253+ . fix_height ( 24.0 )
254+ . expand_width ( ) )
255+ . with_spacer ( 4.0 )
256+ . with_child ( Slider :: new ( )
257+ . with_range ( 0.0 , 1.0 )
258+ . expand_width ( )
259+ . lens ( FractalData :: palette_offset) )
260+ . with_spacer ( 4.0 )
261+ . with_child ( create_label_textbox_row ( "Span:" , 160.0 )
262+ . lens ( FractalData :: palette_iteration_span) )
263+ . with_spacer ( 4.0 )
264+ . with_child ( create_checkbox_row ( "Cyclic palette" ) . lens ( FractalData :: palette_cyclic) )
265+ . with_spacer ( 4.0 )
266+ . with_child ( create_checkbox_row ( "Distance color" ) . lens ( FractalData :: distance_color) )
267+ . with_spacer ( 4.0 )
268+ . with_child ( create_label_textbox_row ( "Stripe Scale:" , 160.0 )
269+ . lens ( FractalData :: stripe_scale) )
270+ . with_spacer ( 4.0 )
271+ . with_child ( create_label_textbox_row ( "Distance Transition:" , 160.0 )
272+ . lens ( FractalData :: distance_transition) )
273+ . with_spacer ( 4.0 )
274+ . with_child ( create_checkbox_row ( "Lighting" ) . lens ( FractalData :: lighting) )
275+ . with_spacer ( 4.0 )
276+ . with_child ( Flex :: row ( )
277+ . with_child ( Label :: new ( "Direction:" ) . fix_width ( 100.0 ) )
278+ . with_flex_child ( Slider :: new ( )
279+ . with_range ( 0.0 , 180.0 )
280+ . expand_width ( )
281+ . lens ( FractalData :: lighting_direction. map ( |val| * val / 2.0 , |new, val| * new = 2.0 * val. round ( ) ) ) , 1.0 )
282+ . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
283+ format ! ( "{:>3.0}°" , * data)
284+ } ) . lens ( FractalData :: lighting_direction) ) )
285+ . with_spacer ( 4.0 )
286+ . with_child ( Flex :: row ( )
287+ . with_child ( Label :: new ( "Azimuth:" ) . fix_width ( 100.0 ) )
288+ . with_flex_child ( Slider :: new ( )
289+ . with_range ( 0.0 , 90.0 )
290+ . expand_width ( )
291+ . lens ( FractalData :: lighting_azimuth. map ( |val| * val, |new, val| * new = val. round ( ) ) ) , 1.0 )
292+ . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
293+ format ! ( "{:>3.0}°" , * data)
294+ } ) . lens ( FractalData :: lighting_azimuth) ) )
295+ . with_spacer ( 4.0 )
296+ . with_child ( Flex :: row ( )
297+ . with_child ( Label :: new ( "Opacity:" ) . fix_width ( 100.0 ) )
298+ . with_flex_child ( Slider :: new ( )
299+ . with_range ( 0.0 , 1.0 )
300+ . expand_width ( )
301+ . lens ( FractalData :: lighting_opacity) , 1.0 )
302+ . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
303+ format ! ( "{:>4.1}%" , 100.0 * * data)
304+ } ) . lens ( FractalData :: lighting_opacity) ) )
305+ . with_spacer ( 4.0 )
306+ . with_child ( Flex :: row ( )
307+ . with_child ( Label :: new ( "Ambient:" ) . fix_width ( 100.0 ) )
308+ . with_flex_child ( Slider :: new ( )
309+ . with_range ( 0.0 , 1.0 )
310+ . expand_width ( )
311+ . lens ( FractalData :: lighting_ambient) , 1.0 )
312+ . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
313+ format ! ( "{:>4.1}%" , 100.0 * * data)
314+ } ) . lens ( FractalData :: lighting_ambient) ) )
315+ . with_spacer ( 4.0 )
316+ . with_child ( Flex :: row ( )
317+ . with_child ( Label :: new ( "Diffuse:" ) . fix_width ( 100.0 ) )
318+ . with_flex_child ( Slider :: new ( )
319+ . with_range ( 0.0 , 1.0 )
320+ . expand_width ( )
321+ . lens ( FractalData :: lighting_diffuse) , 1.0 )
322+ . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
323+ format ! ( "{:>4.1}%" , 100.0 * * data)
324+ } ) . lens ( FractalData :: lighting_diffuse) ) )
325+ . with_spacer ( 4.0 )
326+ . with_child ( Flex :: row ( )
327+ . with_child ( Label :: new ( "Specular:" ) . fix_width ( 100.0 ) )
328+ . with_flex_child ( Slider :: new ( )
329+ . with_range ( 0.0 , 1.0 )
330+ . expand_width ( )
331+ . lens ( FractalData :: lighting_specular) , 1.0 )
332+ . with_child ( Label :: < f64 > :: new ( |data : & f64 , _env : & _ | {
333+ format ! ( "{:>4.1}%" , 100.0 * * data)
334+ } ) . lens ( FractalData :: lighting_specular) ) )
335+ . with_spacer ( 4.0 )
336+ . with_child ( Flex :: row ( )
337+ . with_child ( Label :: new ( "Shininess:" ) . fix_width ( 100.0 ) )
338+ . with_flex_child ( Slider :: new ( )
339+ . with_range ( 0.0 , 50.0 )
340+ . expand_width ( )
341+ . lens ( FractalData :: lighting_shininess. map ( |val| * val as f64 , |new, val| * new = val as i64 ) ) , 1.0 )
342+ . with_child ( Label :: < i64 > :: new ( |data : & i64 , _env : & _ | {
343+ format ! ( "{:>4}" , * data)
344+ } ) . lens ( FractalData :: lighting_shininess) ) )
345+ . with_spacer ( 4.0 )
346+ . with_child ( Button :: new ( "SET" ) . on_click ( |ctx, _data : & mut FractalData , _env| {
347+ ctx. submit_command ( SET_OFFSET_SPAN ) ;
348+ } ) . expand_width ( ) . fix_height ( 36.0 ) ) ;
355349
356350 let group_information = Flex :: column ( )
357351 . with_child ( Flex :: row ( )
0 commit comments