execute-glib-cleanup
gobject-alien)
(import (pango)
- ->color color-red color-green color-blue color-alpha
- guarantee-color
+ ->color
guarantee-pango-layout)
(export (cairo)
cairo-image-surface-create
(C-include "cairo")
+(define-integrable (color-red o) (flo:vector-ref o 0))
+(define-integrable (color-green o) (flo:vector-ref o 1))
+(define-integrable (color-blue o) (flo:vector-ref o 2))
+(define-integrable (color-alpha o) (flo:vector-ref o 3))
+
+(define (guarantee-color object operator)
+ (if (not (and (flo:flonum? object) (fix:= 4 (flo:vector-length object))))
+ (error:wrong-type-argument object "an rgba color" operator)))
+
(define (cairo-image-surface-create width height)
(let ((surface (make-alien '|cairo_surface_t|))
(copy (make-alien '|cairo_surface_t|)))
assert-glib-locked assert-without-interruption
gobject-alien gobject-unref!)
(import (pango)
- make-rgba-color
pango-context-get-metrics
pango-context-spacing
pango-font-description-free
(set-rectangle-ink-color! cursor "green")
(set-rectangle-ink-fill-color! cursor (make-rgba-color 0. 1. 0. .5)))
+(define (make-rgba-color red green blue alpha)
+ (let ((color (flo:vector-cons 4)))
+ (flo:vector-set! color 0 red)
+ (flo:vector-set! color 1 green)
+ (flo:vector-set! color 2 blue)
+ (flo:vector-set! color 3 alpha)
+ color))
+
(define (guarantee-cursor-ink object)
(if (cursor-ink? object) object
(error:wrong-type-argument object "<cursor-ink>" 'guarantee-cursor-ink)))
(define (bit-ior . ints)
(reduce bitwise-ior 0 ints))
-(define-integrable (color? object)
+(define (color? object)
(and (flo:flonum? object) (fix:= 4 (flo:vector-length object))))
-(define-integrable (make-color) (flo:vector-cons 4))
-(define-integrable-operator (color-red o)
- (if (color? o) (flo:vector-ref o 0) (error:wrong-type-argument o "a color")))
-(define-integrable-operator (color-green o)
- (if (color? o) (flo:vector-ref o 1) (error:wrong-type-argument o "a color")))
-(define-integrable-operator (color-blue o)
- (if (color? o) (flo:vector-ref o 2) (error:wrong-type-argument o "a color")))
-(define-integrable-operator (color-alpha o)
- (if (color? o) (flo:vector-ref o 3) (error:wrong-type-argument o "a color")))
-(define-integrable-operator (set-color-red! o r)
- (if (color? o) (flo:vector-set! o 0 r)(error:wrong-type-argument o"a color")))
-(define-integrable-operator (set-color-green! o g)
- (if (color? o) (flo:vector-set! o 1 g)(error:wrong-type-argument o"a color")))
-(define-integrable-operator (set-color-blue! o b)
- (if (color? o) (flo:vector-set! o 2 b)(error:wrong-type-argument o"a color")))
-(define-integrable-operator (set-color-alpha! o a)
- (if (color? o) (flo:vector-set! o 3 a)(error:wrong-type-argument o"a color")))
-(define-integrable-operator (make-rgba-color red green blue alpha)
- (let ((color (make-color)))
- (set-color-red! color red)
- (set-color-green! color green)
- (set-color-blue! color blue)
- (set-color-alpha! color alpha)
+
+(define (make-rgba-color red green blue alpha)
+ (let ((color (flo:vector-cons 4)))
+ (flo:vector-set! color 0 red)
+ (flo:vector-set! color 1 green)
+ (flo:vector-set! color 2 blue)
+ (flo:vector-set! color 3 alpha)
color))
\ No newline at end of file
(files "pango")
;;(depends-on "../glib/glib.ext")
(export (pango)
- color? make-color color-red color-green color-blue color-alpha
- set-color-red! set-color-green! set-color-blue! set-color-alpha!
- make-rgba-color guarantee-color
->color pango-color-parse
<pango-layout> guarantee-pango-layout
pango-layout-get-context
(if (alien-null? ALIEN)
(error MESSAGE ...)))))
-(define-integrable (color? object)
+(define (color? object)
(and (flo:flonum? object) (fix:= 4 (flo:vector-length object))))
(define-integrable (make-color) (flo:vector-cons 4))
(define-integrable (set-color-blue! o b) (flo:vector-set! o 2 b))
(define-integrable (set-color-alpha! o a) (flo:vector-set! o 3 a))
-(define-integrable (make-rgba-color red green blue alpha)
+(define (rgba-color red green blue alpha)
(let ((color (make-color)))
(set-color-red! color red)
(set-color-green! color green)
(set-color-alpha! color alpha)
color))
-(define (guarantee-color object operator)
- (if (color? object)
- object
- (error:wrong-type-argument object "a color" operator)))
-
-(define white (make-rgba-color 1. 1. 1. 1.))
-(define black (make-rgba-color 0. 0. 0. 1.))
+(define white (rgba-color 1. 1. 1. 1.))
+(define black (rgba-color 0. 0. 0. 1.))
(define (->color spec operator)
(assert-glib-locked '->color)