/[cl-cairo2]/cairo.lisp
ViewVC logotype

Contents of /cairo.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (show annotations)
Thu Jul 12 14:01:08 2007 UTC (6 years, 9 months ago) by tpapp
File size: 1409 byte(s)
Code cleanup, also added finalizers
1 (in-package :cl-cairo2)
2
3 ;; (define-foreign-library libcairo
4 ;; (:unix (:or "libcairo.so.2" "libcairo.so"))
5 ;; (t (:default "libcairo")))
6
7 ;; (use-foreign-library libcairo)
8
9 (load-foreign-library '(:default "libcairo"))
10
11 (defun deg-to-rad (deg)
12 "Convert degrees to radians."
13 (* deg (/ pi 180.0d0)))
14
15 (defgeneric destroy (object)
16 (:documentation "Destroys Cairo object."))
17 (export 'destroy)
18
19 ;;;;
20 ;;;; commonly used macros/functions
21 ;;;;
22
23 (defun prepend-intern (prefix name &key (replace-dash t) (suffix ""))
24 "Create and intern symbol PREFIXNAME from NAME, optionally
25 replacing dashes in name. PREFIX is converted to upper case.
26 If given, suffix is appended at the end."
27 (let ((name-as-string (symbol-name name)))
28 (when replace-dash
29 (setf name-as-string (substitute #\_ #\- name-as-string)))
30 (intern (concatenate 'string (string-upcase prefix)
31 name-as-string (string-upcase suffix)))))
32
33 (defun copy-double-vector-to-pointer (vector pointer)
34 "Copies vector of double-floats to a memory location."
35 (dotimes (i (length vector))
36 (setf (mem-aref pointer :double i) (coerce (aref vector i) 'double-float))))
37
38 (defun copy-pointer-to-double-vector (length pointer)
39 "Copies the contents of a memory location to a vector of a double-floats."
40 (let ((vector (make-array length)))
41 (dotimes (i length vector)
42 (setf (aref vector i) (mem-aref pointer :double i)))))

  ViewVC Help
Powered by ViewVC 1.1.5