Changeset 36594 in project


Ignore:
Timestamp:
09/13/18 20:00:18 (6 days ago)
Author:
mario
Message:

eggref/4/cairo: add example by C-Keen

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/cairo

    r31290 r36594  
    1919
    2020Currently there is no documentation, see the source-files for more information.
     21
     22=== Examples
     23
     24By [[/users/christian-kellermann|Christian Kellermann]]:
     25
     26<enscript highlight=scheme>
     27(import scheme (chicken base) cairo miscmacros (chicken random))
     28
     29(define *rotation* 0)
     30(define *delta* 2.7)
     31(define *width* 18)
     32(define *height* 26)
     33(define *box-size* 15)
     34
     35(define s (cairo-pdf-surface-create "schotter.pdf" 842 1190)) ; A3
     36(define c (cairo-create s))
     37
     38;; use millimeters as units from here on
     39(cairo-scale c (/ 72 25.4) (/ 72 25.4))
     40(cairo-set-source-rgba c 1 0 0 1)
     41
     42(dotimes (y *height*)
     43  (dotimes (x *width*)
     44    (cairo-save c)
     45    (cairo-set-line-width c .3)
     46    (cairo-translate c (+ 12 (* x *box-size*)) (+ 16 (* y *box-size*)))
     47    (cairo-rotate c (* (if (> 1 (pseudo-random-integer 2)) -1 1)
     48                       (/ cairo-pi 180)
     49                       (* *rotation*  (pseudo-random-real))))
     50    (cairo-rectangle c 0 0 *box-size* *box-size*)
     51    (cairo-set-source-rgba c 0 0 0 1)
     52    (cairo-stroke c)
     53    (cairo-restore c))
     54  (set! *rotation* (+ *rotation* *delta*)))
     55
     56(cairo-surface-show-page s)
     57(cairo-destroy c)
     58(cairo-surface-finish s)
     59(cairo-surface-destroy s)
     60</enscript>
     61
     62Output:
     63
     64[[image://www.call-cc.org/img/cairo/georg-nees.png|Homage to Georg Nees]]
     65
    2166
    2267=== Author
Note: See TracChangeset for help on using the changeset viewer.