package-gloss.md 930 Bytes
Newer Older
IC Rainbow's avatar
IC Rainbow committed
1
2
3
4
5
6
7
8
9
---
tags: [package, gloss]
---

# Gloss

- Hackage: <https://hackage.haskell.org/package/gloss>
- Source: <https://github.com/benl23x5/gloss>

IC Rainbow's avatar
IC Rainbow committed
10
> Gloss hides the pain of drawing simple vector graphics behind a nice data type and a few display functions. Gloss uses OpenGL under the hood, but you won't need to worry about any of that. Get something cool on the screen in under 10 minutes.
IC Rainbow's avatar
IC Rainbow committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

## Minimal example

```haskell
-- | Display "Hello World" in a window.
import Graphics.Gloss

main :: IO ()
main =
  display
    (InWindow
      "Hello World" -- window title
      (400, 150)    -- window size
      (10, 10)      -- window position
    )
  white   -- background color
  picture -- picture to display

picture :: Picture
picture =
  -- shift the text to the middle of the window
  Translate (-170) (-20) $
    -- display it half the original size
    Scale 0.5 0.5 $
      -- the shape is a text
      Text "Hello World"
```