[cl-cairo2-cvs] r10 - tutorial

tpapp at common-lisp.net tpapp at common-lisp.net
Thu Jul 26 14:52:20 UTC 2007


Author: tpapp
Date: Thu Jul 26 10:52:20 2007
New Revision: 10

Modified:
   cl-cairo2-swig.lisp
   cl-cairo2.asd
   cl-cairo2.i
   context.lisp
   package.lisp
   tutorial/tutorial.tex
Log:
interface using cl-colors added

Modified: cl-cairo2-swig.lisp
==============================================================================
--- cl-cairo2-swig.lisp	(original)
+++ cl-cairo2-swig.lisp	Thu Jul 26 10:52:20 2007
@@ -2,10 +2,10 @@
 (in-package :cl-cairo2)
 
 (defctype my-double :double)
-(defmethod cffi:expand-to-foreign (value (type (eql 'my-double)))
-  `(coerce ,value 'double-float))
-;; (defmethod translate-to-foreign (value (type my-double))
-;;   (coerce value 'double-float))
+;; (defmethod cffi:expand-to-foreign (value (type (eql 'my-double)))
+;;   `(coerce ,value 'double-float))
+(defmethod translate-to-foreign (value (type (eql 'my-double)))
+   (coerce value 'double-float))
 
 ;; typedefs: we don't want to create all of them automatically,
 ;; because typedefs for structures confuse with-foreign-slots

Modified: cl-cairo2.asd
==============================================================================
--- cl-cairo2.asd	(original)
+++ cl-cairo2.asd	Thu Jul 26 10:52:20 2007
@@ -1,6 +1,6 @@
 (defsystem cl-cairo2
   :description "Cairo 1.4 bindings"
-  :version "0.2.2"
+  :version "0.2.3"
   :author "Tamas K Papp"
   :license "GPL"
   :components ((:file "package")
@@ -15,4 +15,4 @@
 	       (:file "xlib-context" :depends-on ("context")
 				     :in-order-to ((load-op (feature :unix))
 						   (compile-op (feature :unix)))))
-  :depends-on (:cffi))
+  :depends-on (:cffi :cl-colors))

Modified: cl-cairo2.i
==============================================================================
--- cl-cairo2.i	(original)
+++ cl-cairo2.i	Thu Jul 26 10:52:20 2007
@@ -10,10 +10,10 @@
 (in-package :cl-cairo2)
 
 (defctype my-double :double)
-(defmethod cffi:expand-to-foreign (value (type (eql 'my-double)))
-  `(coerce ,value 'double-float))
-;; (defmethod translate-to-foreign (value (type my-double))
-;;   (coerce value 'double-float))
+;; (defmethod cffi:expand-to-foreign (value (type (eql 'my-double)))
+;;   `(coerce ,value 'double-float))
+(defmethod translate-to-foreign (value (type (eql 'my-double)))
+   (coerce value 'double-float))
 
 ;; typedefs: we don't want to create all of them automatically,
 ;; because typedefs for structures confuse with-foreign-slots

Modified: context.lisp
==============================================================================
--- context.lisp	(original)
+++ context.lisp	Thu Jul 26 10:52:20 2007
@@ -150,6 +150,29 @@
 (define-with-default-context-sync stroke)
 (define-with-default-context-sync stroke-preserve)
 
+;;;;
+;;;; set colors using the color library
+;;;;
+(defgeneric set-source-color (color &optional context))
+
+(defmethod set-source-color 
+    ((color rgb-color) &optional (context *context*))
+  (set-source-rgb 
+   (rgb-color-red color)
+   (rgb-color-green color)
+   (rgb-color-blue color)
+   context))
+
+(defmethod set-source-color 
+    ((color rgba-color) &optional (context *context*))
+  (set-source-rgba 
+   (rgba-color-red color)
+   (rgba-color-green color)
+   (rgba-color-blue color)
+   (rgba-color-alpha color)
+   context))
+  
+
 ;;;; 
 ;;;; functions that get/set a property without any conversion
 ;;;; 

Modified: package.lisp
==============================================================================
--- package.lisp	(original)
+++ package.lisp	Thu Jul 26 10:52:20 2007
@@ -1,5 +1,5 @@
 (defpackage :cl-cairo2
-   (:use :common-lisp :cffi)
+   (:use :common-lisp :cffi :cl-colors)
    (:export 				; !!! when the interface
 					; stabilizes, remove export's
 					; from all other places and
@@ -7,7 +7,7 @@
     ;; utility functions
     deg-to-rad
     ;; context
-    *context*
+    *context* set-source-color
     ;; transformations
     make-trans-matrix trans-matrix-xx trans-matrix-yx trans-matrix-xy
     trans-matrix-yy trans-matrix-x0 trans-matrix-y0 trans-matrix-p))

Modified: tutorial/tutorial.tex
==============================================================================
--- tutorial/tutorial.tex	(original)
+++ tutorial/tutorial.tex	Thu Jul 26 10:52:20 2007
@@ -261,6 +261,14 @@
 I doubt that Lisp users need \lstinline!get/set-user-data! or
 \lstinline!get-reference-count!.  Let me know if you do.
 
+Since version 0.2.3, you can use colors from
+\href{http://www.cliki.net/cl-colors}{cl-colors} with the generic
+function \lstinline!set-source-color!, for example,
+\begin{lstlisting}
+  (set-source-color +darkolivegreen+)
+\end{lstlisting}
+
+
 \subsection{Paths}
 \label{sec:paths}
 



More information about the Cl-cairo2-cvs mailing list