oscpacking-0.1.0.0: Interpret.hs
{--
This file is part of the OscPacking library.
Copyright 2016 Christopher Howard.
OscPacking is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OscPacking is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OscPacking. If not, see <http://www.gnu.org/licenses/>.
--}
module Interpret where
import Geometry
import Graphics.Gloss.Data.Picture hiding (Circle, Point)
import qualified Graphics.Gloss.Data.Picture as P (Picture(Circle))
import Graphics.Gloss.Data.Color
import Data.Colour.RGBSpace
import Data.Colour.RGBSpace.HSL
type Interpretation = [Circle] -> Picture
monoWhite :: Interpretation
monoWhite = (Pictures . map mF)
where mF (Circle { radius = r, position = p }) =
Translate (fst p) (snd p) (Color white (P.Circle r))
-- hue :: Int -> Color
hue degrees =
let rgb = hsl degrees 1 0.7
(red, green, blue) = (channelRed rgb, channelGreen rgb, channelBlue rgb)
in makeColor red green blue 1.0
colorful :: Float -> Interpretation
colorful offset = (Pictures . map mF)
where mF (Circle { radius = r, position = p }) =
Translate (fst p) (snd p)
(Color (Interpret.hue
(fromInteger (mod (floor ((r + offset)**2)) 360)))
(P.Circle r))
cycling :: Float -> Float -> Interpretation
cycling speed offset = (Pictures . map mF)
where mF (Circle { radius = r, position = p }) =
Translate (fst p) (snd p)
(Color (Interpret.hue
(offset + (fromInteger (mod (floor ((2*pi*r) * speed)) 360))))
(P.Circle r))