Safe Haskell | Safe-Infered |
---|
Rendering of continuous 2D functions as raster fields.
Gloss programs should be compiled with -threaded
, otherwise the GHC runtime
will limit the frame-rate to around 20Hz.
The performance of programs using this interface is sensitive to how much boxing and unboxing the GHC simplifier manages to eliminate. For the best result add INLINE pragmas to all of your numeric functions and use the following compile options.
-threaded -Odph -fno-liberate-case -funfolding-use-threshold1000 -funfolding-keeness-factor1000 -fllvm -optlo-O3
See the examples the raster
directory of the gloss-examples
package
for more details.
- module Graphics.Gloss.Data.Color
- rgb :: Float -> Float -> Float -> Color
- rgb8 :: Int -> Int -> Int -> Color
- rgb8w :: Word8 -> Word8 -> Word8 -> Color
- data Display
- type Point = (Float, Float)
- animateField :: Display -> (Int, Int) -> (Float -> Point -> Color) -> IO ()
- playField :: Display -> (Int, Int) -> Int -> world -> (world -> Point -> Color) -> (Event -> world -> world) -> (Float -> world -> world) -> IO ()
- makePicture :: Int -> Int -> Int -> Int -> (Point -> Color) -> Picture
- makeFrame :: Int -> Int -> (Point -> Color) -> Array (I D) DIM2 (Word8, Word8, Word8)
Color
module Graphics.Gloss.Data.Color
rgb :: Float -> Float -> Float -> ColorSource
Construct a color from red, green, blue components.
Each component is clipped to the range [0..1]
rgb8 :: Int -> Int -> Int -> ColorSource
Construct a color from red, green, blue components.
Each component is clipped to the range [0..255]
Display functions
data Display
Describes how Gloss should display its output.
A point on the x-y plane.
Points can also be treated as Vector
s, so Graphics.Gloss.Data.Vector
may also be useful.
:: Display | Display mode. |
-> (Int, Int) | Number of pixels to draw per point. |
-> (Float -> Point -> Color) | Function to compute the color at a particular point. It is passed the time in seconds since the program started, and a point between (-1, -1) and (+1, +1). |
-> IO () |
Animate a continuous 2D function.
:: Display | Display mode. |
-> (Int, Int) | Number of pixels to draw per point. |
-> Int | Number of simulation steps to take for each second of real time |
-> world | The initial world. |
-> (world -> Point -> Color) | Function to compute the color of the world at the given point. |
-> (Event -> world -> world) | Function to handle input events. |
-> (Float -> world -> world) | Function to step the world one iteration. It is passed the time in seconds since the program started. |
-> IO () |
Play a game with a continous 2D function.