summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-04-06 15:19:47 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-04-06 15:19:47 +0200
commite5df409e75b942ba89e4c9dfc4a8ab2a7877ebd9 (patch)
tree8bfab5ce05613e93fc5b58ba137c379d04c91bbc
parentafe32f54428d8605a6bf89df8d5bf6948e09751b (diff)
Add simple color support.
-rw-r--r--pict.scm50
1 files changed, 49 insertions, 1 deletions
diff --git a/pict.scm b/pict.scm
index 5279fed..5a5b9b1 100644
--- a/pict.scm
+++ b/pict.scm
@@ -85,7 +85,11 @@
rt-superimpose
rc-superimpose
- rb-superimpose))
+ rb-superimpose
+
+ ;; colors
+ rgb
+ colors))
;;; Records
@@ -757,3 +761,47 @@ bottom."
(define (rb-superimpose . picts)
"Stack the given PICTS and align them right and at the bottom."
(append-align 'right 'bottom picts))
+
+
+;;; Colors
+
+(define (rgb r g b)
+ (when (any (lambda (comp)
+ (or (> comp 255)
+ (negative? comp)))
+ (list r g b))
+ (error "Color component values must be between 0 and 255."))
+ (format #f "rgb(~a,~a,~a)" r g b))
+
+;; List of defined SVG color names
+(define colors
+ (list "aliceblue" "antiquewhite" "aqua" "aquamarine" "azure" "beige"
+ "bisque" "black" "blanchedalmond" "blue" "blueviolet" "brown"
+ "burlywood" "cadetblue" "chartreuse" "chocolate" "coral"
+ "cornflowerblue" "cornsilk" "crimson" "cyan" "darkblue"
+ "darkcyan" "darkgoldenrod" "darkgray" "darkgreen" "darkgrey"
+ "darkkhaki" "darkmagenta" "darkolivegreen" "darkorange"
+ "darkorchid" "darkred" "darksalmon" "darkseagreen"
+ "darkslateblue" "darkslategray" "darkslategrey" "darkturquoise"
+ "darkviolet" "deeppink" "deepskyblue" "dimgray" "dimgrey"
+ "dodgerblue" "firebrick" "floralwhite" "forestgreen" "fuchsia"
+ "gainsboro" "ghostwhite" "gold" "goldenrod" "gray" "grey"
+ "green" "greenyellow" "honeydew" "hotpink" "indianred" "indigo"
+ "ivory" "khaki" "lavender" "lavenderblush" "lawngreen"
+ "lemonchiffon" "lightblue" "lightcoral" "lightcyan"
+ "lightgoldenrodyellow" "lightgray" "lightgreen" "lightgrey"
+ "lightpink" "lightsalmon" "lightseagreen" "lightskyblue"
+ "lightslategray" "lightslategrey" "lightsteelblue"
+ "lightyellow" "lime" "limegreen" "linen" "magenta" "maroon"
+ "mediumaquamarine" "mediumblue" "mediumorchid" "mediumpurple"
+ "mediumseagreen" "mediumslateblue" "mediumspringgreen"
+ "mediumturquoise" "mediumvioletred" "midnightblue" "mintcream"
+ "mistyrose" "moccasin" "navajowhite" "navy" "oldlace" "olive"
+ "olivedrab" "orange" "orangered" "orchid" "palegoldenrod"
+ "palegreen" "paleturquoise" "palevioletred" "papayawhip"
+ "peachpuff" "peru" "pink" "plum" "powderblue" "purple" "red"
+ "rosybrown" "royalblue" "saddlebrown" "salmon" "sandybrown"
+ "seagreen" "seashell" "sienna" "silver" "skyblue" "slateblue"
+ "slategray" "slategrey" "snow" "springgreen" "steelblue" "tan"
+ "teal" "thistle" "tomato" "turquoise" "violet" "wheat" "white"
+ "whitesmoke" "yellow" "yellowgreen"))