;; draw an individual 'bar' in the spectrum
(bind-func draw_spectral_bar
(let ((orange_break 500.0) ;marks transition to orange levels
(red_break 650.0) ;marks transition to red levels
(colour_array:|3,rgb_colour|* (alloc)))
;; fill the colours for the spectral levels
(tfill! (aref-ptr colour_array 0) 0.0 0.8 0.1) ;green
(tfill! (aref-ptr colour_array 1) 0.6 0.5 0.0) ;orange
(tfill! (aref-ptr colour_array 2) 1.0 0.2 0.0) ;red
(lambda (cr bar_index bar_width bar_height)
(let ((bar_width_jittered (+ bar_width
(round (* (* bar_width 0.5)
(- (random) 0.5)))))
(bar_xpos (* (i64tod bar_index)
bar_width)))
;; draw red bars
(if (> bar_height red_break)
(begin
(set_cairo_source_with_colour cr (aref-ptr colour_array 2))
(cairo_rectangle cr
bar_xpos
0.0
bar_width_jittered
bar_height)
(cairo_fill cr)))
;; draw orange bars
(if (> bar_height orange_break)
(begin
(set_cairo_source_with_colour cr (aref-ptr colour_array 1))
(cairo_rectangle cr
bar_xpos
0.0
bar_width_jittered
(if (> bar_height red_break)
red_break bar_height))
(cairo_fill cr)))
;; draw green bars
(set_cairo_source_with_colour cr (aref-ptr colour_array 0))
(cairo_rectangle cr
bar_xpos
0.0
bar_width_jittered
(if (> bar_height orange_break)
orange_break bar_height))
(cairo_fill cr)))))