(parent (glib))
(files "cairo")
(import (pango)
- pango-color-parse
guarantee-pango-layout)
(export ()
cairo-image-surface-create
(let ((c (->color color 'cairo-pattern-add-color-stop)))
(C-call "cairo_pattern_add_color_stop_rgba" pattern (->flonum offset)
(color-red c) (color-green c) (color-blue c) (color-alpha c))))
-
-(define (->color spec operator)
- (cond ((color? spec) spec)
- ((string? spec)
- (pango-color-parse spec))
- (else
- (error:wrong-type-argument spec "a color spec" operator))))
\f
(define (cairo-create surface)
(guarantee-cairo-surface surface 'cairo-create)
(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)
+ color))
\f
;;; GLib Cleanups
(if (set-option!? ink 'COLOR color)
(drawing-damage ink))))))
-(define (->color spec operator)
- (cond ((color? spec) spec)
- ((string? spec)
- (let ((rgba (malloc (C-sizeof "GdkRGBA") '|GdkRGBA|)))
- (if (zero? (C-call "gdk_rgba_parse" rgba spec))
- (error:wrong-type-argument spec "a color spec" operator)
- (let ((color (make-color)))
- (set-color-red! color (C-> rgba "GdkRGBA red"))
- (set-color-green! color (C-> rgba "GdkRGBA green"))
- (set-color-blue! color (C-> rgba "GdkRGBA blue"))
- (set-color-alpha! color (C-> rgba "GdkRGBA alpha"))
- (free rgba)
- color))))
- (else
- (error:wrong-type-argument spec "a color spec" operator))))
-
(define (line-ink-dash-color ink)
(guarantee-line-ink ink 'line-ink-dash-color)
(get-option ink 'DASH-COLOR '()))
(define-package (gtk)
(parent (glib))
(files "gtk")
- ;;(depends-on "gtk-const.bin")
+ ;;(depends-on "gtk-const.bin" "../glib/")
)
(define-package (gtk gdk)
(files "gtk-graphics")
(import (gtk fix-layout)
fix-ink-extent fix-rect-height fix-rect-width
- ->color set-surface-ink-surface! drawing-damage)
+ set-surface-ink-surface! drawing-damage)
(export ()
gtk-graphics/set-background-color
gtk-graphics/set-foreground-color
(files "pango")
;;(depends-on "../glib/glib.ext")
(export ()
- pango-color-parse
+ ->color pango-color-parse
<pango-layout>
pango-layout-get-context
pango-layout-context-changed
(C-include "pango")
+(define white (make-rgba-color 1. 1. 1. 1.))
+(define black (make-rgba-color 0. 0. 0. 1.))
+
+(define (->color spec operator)
+ (cond ((color? spec) spec)
+ ((eq? spec 'WHITE) white)
+ ((eq? spec 'BLACK) black)
+ ((symbol? spec) (pango-color-parse (symbol-name spec)))
+ ((string? spec) (pango-color-parse spec))
+ (else
+ (error:wrong-type-argument spec "a color spec" operator))))
+
(define (pango-color-parse spec)
(guarantee-string spec 'pango-color-parse)
(let ((rgb (malloc (C-sizeof "PangoColor") '|PangoColor|)))