Gloss is easily installed using the Cabal tool. Having installed Cabal, one can run
cabal install gloss to install Gloss.
gloss/gloss-rendering/directory and do
gloss/gloss/directory and once more do
In Gloss, one can use the
display function to create very simple static graphics.
To use this one needs to first
import Graphics.Gloss. Then in the code there should the following:
main :: IO () main = display window background drawing
window is of type
Display which can be constructed in two ways:
-- Defines window as an actual window with a given name and size window = InWindow name (width, height) (0,0) -- Defines window as a fullscreen window window = FullScreen
Here the last argument
InWindow marks the location of the top left corner.
For versions older than 1.11: In older versions of Gloss
FullScreen takes another argument which is meant to be the size of the frame that gets drawn on which in turn gets stretched to fullscreen-size, for example:
background is of type
Color. It defines the background color, so it's as simple as:
background = white
Then we get to the drawing itself. Drawings can be very complex. How to specify these will be covered elsewhere ([one can refer to this for the moment]), but it can be as simple as the following circle with a radius of 80:
drawing = Circle 80
As more or less stated in the documentation on Hackage, getting something on the screen is as easy as:
import Graphics.Gloss main :: IO () main = display window background drawing where window = InWindow "Nice Window" (200, 200) (0, 0) background = white drawing = Circle 80