Skip to content

Commit a65126e

Browse files
author
Anton Pirogov
committed
fix ellipse/circle coordinate reference, add travis-ci
1 parent 4dd388c commit a65126e

File tree

5 files changed

+82
-6
lines changed

5 files changed

+82
-6
lines changed

.travis.yml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
language: c
2+
3+
# explicitly request container-based infrastructure
4+
sudo: false
5+
6+
# See also https://github.com/hvr/multi-ghc-travis for more information
7+
matrix:
8+
include:
9+
- env: CABALVER=1.18 GHCVER=7.8.4
10+
addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4], sources: [hvr-ghc]}}
11+
- env: CABALVER=1.22 GHCVER=7.10.2
12+
addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2],sources: [hvr-ghc]}}
13+
- env: CABALVER=head GHCVER=head
14+
addons: {apt: {packages: [cabal-install-head,ghc-head], sources: [hvr-ghc]}}
15+
allow_failures:
16+
- env: CABALVER=head GHCVER=head
17+
18+
before_install:
19+
- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
20+
21+
# build SDL2 if necessary
22+
- bash travis-install-sdl2.sh
23+
- export PATH=$HOME/libsdl2/bin:$HOME/.cabal/bin:$PATH
24+
- export PKG_CONFIG_PATH=$HOME/libsdl2/lib/pkgconfig
25+
26+
cache:
27+
directories:
28+
- $HOME/libsdl2
29+
30+
install:
31+
- cabal --version
32+
- echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
33+
- travis_retry cabal update
34+
35+
# install stuff that will confuse cabal otherwise
36+
- cabal install alex happy
37+
- cabal install gtk2hs-buildtools
38+
- cabal install "sdl2>=2.0.0" --extra-include-dirs=$HOME/libsdl2/include --extra-lib-dirs=$HOME/libsdl2/lib
39+
40+
- cabal install --only-dependencies --enable-tests --enable-benchmarks
41+
42+
# Here starts the actual work to be performed for the package under test; any command which exits with a non-zero exit code causes the build to fail.
43+
script:
44+
- if [ -f configure.ac ]; then autoreconf -i; fi
45+
- cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
46+
- cabal build # this builds all libraries and executables (including tests/benchmarks)
47+
- cabal test
48+
- cabal check
49+
- cabal sdist # tests that a source-distribution can be generated
50+
51+
# Check that the resulting source distribution can be built & installed.
52+
# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
53+
# `cabal install --force-reinstalls dist/*-*.tar.gz`
54+
- SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
55+
(cd dist && cabal install --force-reinstalls "$SRC_TGZ")
56+
57+
notifications:
58+
email: false
59+

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# sdl2-cairo
1+
# sdl2-cairo [![Hackage version](https://img.shields.io/hackage/v/sdl2-cairo.svg?style=flat)](https://hackage.haskell.org/package/sdl2-cairo) [![Build Status](https://travis-ci.org/apirogov/sdl2-cairo.svg)](https://travis-ci.org/apirogov/sdl2-cairo)
22

33
Haskell library providing functions to use Cairo to draw on SDL textures and containing a Processing-style convenience drawing API.
44

sdl2-cairo.cabal

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
name: sdl2-cairo
55
version: 0.1.0.1
6-
synopsis: Binding to render with Cairo on SDL textures
7-
and optional convenience drawing API.
6+
synopsis: Render with Cairo on SDL textures. Includes optional convenience drawing API.
87
description: This small library provides convenience functions to draw
98
on SDL2 textures with Cairo. As Cairo is complicated, it also
109
provides a drawing API, which is heavily inspired by Processing and
@@ -25,7 +24,7 @@ library
2524
default-language: Haskell2010
2625
exposed-modules: SDL.Cairo, SDL.Cairo.Canvas, SDL.Cairo.Canvas.Interactive
2726
--other-modules:
28-
build-depends: base >=4.8 && <=5
27+
build-depends: base >=4.7 && <=5
2928
, sdl2 >=2.0.0
3029
, cairo >=0.13
3130
, linear

src/SDL/Cairo/Canvas.hs

+5-2
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ module SDL.Cairo.Canvas (
6666
module Graphics.Rendering.Cairo
6767
) where
6868

69+
import Control.Applicative
6970
import Data.Monoid
7071
import Control.Monad.State
7172
import Data.Word (Word8)
@@ -292,7 +293,7 @@ shape ShapeTriangleFan _ = return ()
292293
arc :: Dim -> Double -> Double -> Canvas ()
293294
arc (D x y w h) sa ea = drawShape $ do
294295
C.save
295-
C.translate x y
296+
C.translate (x+(w/2)) (y+(h/2))
296297
C.scale (w/2) (h/2)
297298
C.arc 0 0 1 sa ea
298299
C.restore
@@ -469,7 +470,9 @@ drawShape m = do
469470

470471
-- |if color (csFG/csBG) is set, perform given render block
471472
ifColor :: (CanvasState -> Maybe Color) -> (Color -> Render ()) -> Canvas ()
472-
ifColor cf m = get >>= \cs -> forM_ (cf cs) $ \c -> renderCairo (m c)
473+
ifColor cf m = get >>= \cs -> case cf cs of
474+
Just c -> renderCairo (m c)
475+
Nothing -> return ()
473476

474477
-- |convert from 256-value RGBA to Double representation, set color
475478
setColor :: Color -> Render ()

travis-install-sdl2.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
set -e
3+
if [ ! -d "$HOME/libsdl2/lib" ]; then
4+
hg clone https://hg.libsdl.org/SDL SDL
5+
pushd .
6+
cd SDL
7+
mkdir build
8+
cd build
9+
../configure --prefix=$HOME/libsdl2
10+
make
11+
make install
12+
popd
13+
else
14+
echo "Using cached directory."
15+
fi

0 commit comments

Comments
 (0)