Go to the first, previous, next, last section, table of contents.

Scale in action


colourMixer :: DC -> IO DisplayHandle
colourMixer dc =
  let
   win   = getDCWindow dc
  in
  scale XAxis 0 255 dc      >>= \ (red,red_dh) ->
  scale XAxis 0 255 dc      >>= \ (green,green_dh) ->
  scale XAxis 0 255 dc      >>= \ (blue,blue_dh) ->
  newColour win black       >>= \ pix ->
  glyph (withColour black $
         fillSolid $ 
         square 100) dc     >>= \ (_,dh) ->
  combineGauges (map (getScaleGauge) [red,green,blue]) >>= \ gauge ->
  let
   rgb_slider = 
      mapGauge
         (\ [a,b,c] -> (a*255,b*255,c*255))
         (\ (a,b,c) -> [a/255,b/255,c/255])
         gauge

   colourControl =
    waitGaugeChange rgb_slider         >>= \(triplet,_) ->
    changePixel win pix (rgb triplet)  >>
    colourControl
  in   
  forkIO colourControl >>
  return (hbox [vbox [red_dh,
                      green_dh,
                      blue_dh],
                dh])

main =
 mkDC []         >>= \dc -> 
  colourMixer dc >>= \dh ->
 realiseDH dc dh

Colour mixer

[ToDo: insert explanation of what the above example is actually doing.]


Go to the first, previous, next, last section, table of contents.