chickadee » cairo

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

cairo

Chicken bindings for Cairo, a vector graphics library.

Usage

(require-extension cairo)

Documentation

To build this extension, you will need a current version of cairo. To build/run the test-program, the sdl egg is required.

Currently there is no documentation, see the source-files for more information.

Examples

By Christian Kellermann:

(import scheme (chicken base) cairo miscmacros (chicken random))

(define *rotation* 0)
(define *delta* 2.7)
(define *width* 18)
(define *height* 26)
(define *box-size* 15)

(define s (cairo-pdf-surface-create "schotter.pdf" 842 1190)) ; A3
(define c (cairo-create s))

;; use millimeters as units from here on
(cairo-scale c (/ 72 25.4) (/ 72 25.4))
(cairo-set-source-rgba c 1 0 0 1)

(dotimes (y *height*)
  (dotimes (x *width*)
    (cairo-save c)
    (cairo-set-line-width c .3)
    (cairo-translate c (+ 12 (* x *box-size*)) (+ 16 (* y *box-size*)))
    (cairo-rotate c (* (if (> 1 (pseudo-random-integer 2)) -1 1)
                       (/ cairo-pi 180)
                       (* *rotation*  (pseudo-random-real))))
    (cairo-rectangle c 0 0 *box-size* *box-size*)
    (cairo-set-source-rgba c 0 0 0 1)
    (cairo-stroke c)
    (cairo-restore c))
  (set! *rotation* (+ *rotation* *delta*)))

(cairo-surface-show-page s)
(cairo-destroy c)
(cairo-surface-finish s)
(cairo-surface-destroy s)

Output:

Author

Michael Bridgen and Tony Garnock-Jones

Version History

0.1.15
Support for blend mode operators thanks to Matt Gushee
0.1.14
Support for rectangle-from-surface and mask-surface procedure
0.1.13
Support for pdf/svg/ps surfaces, thanks to Markus Klotzbücher, get-width, get-height for surfaces added, FFI bugfixes.
0.1.12
Bugfix for #762, fixes record-printers, thanks to Markus Klotzbücher, Peter and Felix
0.1.11
Fix wrong pointer type in FFI
0.1.10
also mark linker options returned by pkg-config, so -pthread gets recognised as linker option
0.1.9
parses options returned by pkg-config (thanks to bpowers)
0.1.8
fixed use of removed foreign type pointer
0.1.7
cairo.setup bug fix regarding to eggdoc obsolete code
0.1.6
Fixed incorrect SDL-header include in test-cairo.scm (thanks to Markus Klotzbuecher)
0.1.4 (alpha)
PNG and additional surface functions by Michael McDermott
0.1.3 (alpha)
Initial release

License

Copyright (C) 2004, 2005 Michael Bridgen and Tony Garnock-Jones

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA