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

Contents of /cairo.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7 - (hide 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 tpapp 1 (in-package :cl-cairo2)
2    
3 tpapp 7 ;; (define-foreign-library libcairo
4     ;; (:unix (:or "libcairo.so.2" "libcairo.so"))
5     ;; (t (:default "libcairo")))
6 tpapp 1
7 tpapp 7 ;; (use-foreign-library libcairo)
8 tpapp 1
9 tpapp 7 (load-foreign-library '(:default "libcairo"))
10    
11 tpapp 1 (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 tpapp 6 (defun prepend-intern (prefix name &key (replace-dash t) (suffix ""))
24 tpapp 1 "Create and intern symbol PREFIXNAME from NAME, optionally
25 tpapp 6 replacing dashes in name. PREFIX is converted to upper case.
26     If given, suffix is appended at the end."
27 tpapp 1 (let ((name-as-string (symbol-name name)))
28     (when replace-dash
29     (setf name-as-string (substitute #\_ #\- name-as-string)))
30 tpapp 6 (intern (concatenate 'string (string-upcase prefix)
31     name-as-string (string-upcase suffix)))))
32 tpapp 1
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