guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Example usages of guile-cairo


From: Panicz Maciej Godek
Subject: Example usages of guile-cairo
Date: Wed, 6 Jul 2016 22:01:52 +0200

Hi,
I've been trying to cooperate with guile-cairo. However, the documentation
serves as a reference rather than a tutorial, and I've been trying to agree
the tutorial from the Cairo website with guile bindings, to no avail.

After evaluating the following code, the svg (or pdf) file gets generated,
but it is (in both cases) completely blank. The textual content of the svg
and pdf files suggests that the drawing commands have indeed been issued,
but apparently something's wrong.

(cairo-version) reports 11406.

So, here comes the code (based on the first snippet in the "Drawing with
Cairo" section from https://cairographics.org/tutorial/).

Note (BUG) by the way, that the order of arguments to
cairo-*-surface-create is reversed compared to the documentation, which
claims that the output file name should come first.


(use-modules (cairo))


(define s (cairo-svg-surface-create 200 300 "test.svg"))


;;(define s (cairo-pdf-surface-create  300.0 200.0 "test.pdf"))


(define c (cairo-create s))


(cairo-set-source-rgb c 0 0 0)


(cairo-move-to c 0 0)


(cairo-line-to c 1 1)


(cairo-move-to c 1 0)


(cairo-line-to c 0 1)


(cairo-set-line-width c 0.2)


(cairo-stroke c)


(cairo-rectangle c 0 0 0.5 0.5)


(cairo-set-source-rgba c 1 0 0 0.80)


(cairo-fill c)


(cairo-rectangle c 0 0.5 0.5 0.5)


(cairo-set-source-rgba c 0 1 0 0.60)


(cairo-fill c)


(cairo-rectangle c 0.5 0 0.5 0.5)


(cairo-set-source-rgba c 0 0 1 0.40)


(cairo-fill c)


(cairo-surface-finish s)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]