blob: d390c5d5f1e1b4c5fb81b975736bad21dc565866 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
(define-module (starlet colours)
#:use-module (oop goops)
#:export (<colour>
make-colour-cmy
make-colour-rgb
colour-as-cmy
white))
(define-class <colour> (<object>)
(type
#:init-form (error "Colour type must be specified")
#:init-keyword #:type
#:getter colour-type)
(value
#:init-form (error "Colour value must be specified")
#:init-keyword #:value
#:getter colour-value))
(define-method (write (col <colour>) port)
(format port "#<<colour> ~a ~a>"
(colour-type col)
(colour-value col)))
(define (make-colour-cmy c m y)
(make <colour>
#:type 'cmy
#:value (list c m y)))
(define (make-colour-rgb r g b)
(make <colour>
#:type 'rgb
#:value (list r g b)))
(define white
(make-colour-cmy 0 0 0))
(define (colour-as-cmy col)
(colour-value col))
|