11.07.2015 Views

Tutorial for the cl-cairo2 package - Common Lisp.net

Tutorial for the cl-cairo2 package - Common Lisp.net

Tutorial for the cl-cairo2 package - Common Lisp.net

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>cl</strong>-<strong>cairo2</strong> tutorialTamás K Papp(defparameter max-angle 40d0)(with-png-file ("hearts.png" :rgb24 width height);; fill with white(rectangle 0 0 width height)(set-source-rgb 1 1 1)(fill-path);; draw <strong>the</strong> hearts(dotimes (i 200)(let ((scaling (+ 5d0 (random 40d0))))(reset-trans-matrix) ; reset matrix(translate (random width) (random height)) ; move <strong>the</strong> origin(scale scaling scaling) ; scale(rotate (deg-to-rad (- (random (* 2 max-angle)) max-angle 180))) ;rotate(heart (+ 0.1 (random 0.7))))));;;;;;;; make a rainbow-like pattern;;;;;;;;(defparameter width 100)(defparameter height 40)(setf *context* (create-pdf-context "pattern.pdf" width height))(with-linear-pattern rainbow (0 0 width 0)‘((0 (0.7 0 0.7 0)) ;rgb(a) color as list(1/6 ,<strong>cl</strong>-colors:+blue+) ;color as <strong>cl</strong>-color(2/6 ,<strong>cl</strong>-colors:+green+)(3/6 ,<strong>cl</strong>-colors:+yellow+)(4/6 ,<strong>cl</strong>-colors:+orange+)(5/6 ,<strong>cl</strong>-colors:+red+)(1 ,<strong>cl</strong>-colors:+violetred+))(rectangle 0 0 width height)(set-source rainbow)(fill-path))(destroy *context*)14

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!