https://github.com/apirogov/cairo-canvas
A simpler drawing API for Cairo. Inspired by the Processing language.
https://github.com/apirogov/cairo-canvas
Last synced: about 1 month ago
JSON representation
A simpler drawing API for Cairo. Inspired by the Processing language.
- Host: GitHub
- URL: https://github.com/apirogov/cairo-canvas
- Owner: apirogov
- License: mit
- Created: 2017-08-13T14:15:42.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-05-12T20:09:34.000Z (about 1 year ago)
- Last Synced: 2026-01-19T16:46:23.337Z (5 months ago)
- Language: Haskell
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cairo-canvas [](https://hackage.haskell.org/package/cairo-canvas) [](https://travis-ci.org/apirogov/cairo-canvas)
Haskell library providing an alternative drawing API for Cairo
which is heavily inspired by [Processing](https://processing.org/reference).
##### Install
This library depends on the [cairo bindings](https://hackage.haskell.org/package/cairo).
You also need the [SDL2 bindings](http://hackage.haskell.org/package/sdl2), if you want to build the demo.
Just clone and install this repository:
```bash
git clone git@github.com:apirogov/cairo-canvas.git
cd cairo-canvas
stack install
```
It should work with recent GHC versions (>= 7.8.4) without problems under Linux und OS X.
##### Documentation
Generate the haddock documentation for reference.
```haskell
import SDL.Cairo
import Graphics.Rendering.Cairo.Canvas
...
texture <- createCairoTexture renderer (V2 800 600)
withCairoTexture' texture $ runCanvas $ do
background $ gray 100
stroke $ red 255
fill $ blue 255 !@ 128
rect $ D 0 0 100 100
rect $ toD (V2 50 50) (V2 150 150)
copy renderer texture Nothing Nothing
present renderer
```
See the source of Main.hs for more examples. You start that demo with:
```bash
stack install --flag cairo-canvas:builddemo
stack exec cairo-canvas-test
```