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...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>cl</strong>-<strong>cairo2</strong> tutorialTamás K PappCairo API name (explanation)cairo_fill (would conflict with <strong>cl</strong>:fill)cairo_identity_matrix (would conflict with matrix algebra<strong>package</strong>s)cairo_matrix_init_identitycairo_matrix_trans<strong>for</strong>m_distancecairo_matrix_trans<strong>for</strong>m_pointcairo_matrix_*<strong>cl</strong>-<strong>cairo2</strong> namefill-pathreset-trans-matrixuse (make-trans-matrix)trans<strong>for</strong>m-distancetrans<strong>for</strong>m-pointtrans-matrix-*4 Implementation notes4.1 GeneralThe <strong>package</strong> contains some helper functions, most notably deg-to-rad, which convertsdegrees to radians. Cairo functions use <strong>the</strong> latter.4.2 SurfacesSee <strong>the</strong> beginning of surface.lisp <strong>for</strong> helper macros used internally to define wrappers <strong>for</strong><strong>the</strong> SWIG-generated CFFI interface (nei<strong>the</strong>r <strong>the</strong> interface not <strong>the</strong>se macros are exported).with-alive-surface checks if <strong>the</strong> pointer <strong>for</strong> a surface object is nil, and check-surfacepointer-statusqueries <strong>the</strong> status of <strong>the</strong> surface after executing body. with-surface is acombination of <strong>the</strong> two, and new-surface-with-check makes a new surface object from apointer, checking its status first.Currently, only Postscript, PDF, SVG and image surfaces (which can be written to PNGfiles) are supported.Drawing in X11 windows is implemented using <strong>the</strong> x11-context <strong>cl</strong>ass — see Section 4.7<strong>for</strong> more in<strong>for</strong>mation. You need to load <strong>the</strong> <strong>cl</strong>-<strong>cairo2</strong>-x11 <strong>package</strong> <strong>for</strong> that.4.3 ContextsContexts are represented as <strong>the</strong> <strong>cl</strong>ass context, which currently only has one slot, a pointerto <strong>the</strong> context. When contexts are destroyed, this is set to nil. As mentioned above, <strong>the</strong>default context is *context*, and it is <strong>the</strong> default <strong>for</strong> <strong>the</strong> last (optional) argument of eachfunction.The macro with-context is similar to with-surface above (it executes <strong>the</strong> body withpointer pointing to <strong>the</strong> object and <strong>the</strong>n checks error status). The functions define-with-default-context defines a function acting on a context given a list of arguments and4

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

Saved successfully!

Ooh no, something went wrong!