]> gitweb.factorcode.org Git - factor.git/commitdiff
html.streams: use color>hex
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 28 Feb 2022 18:01:06 +0000 (10:01 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 28 Feb 2022 18:01:06 +0000 (10:01 -0800)
basis/html/streams/streams.factor

index 1678d895bc4cb3d1a02d2ad371735227b1d1e939..cee4c0bfa7e9fc4664c7594a2975786b0f875b6d 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2004, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs combinators destructors html io
+USING: accessors assocs colors combinators destructors html io
 io.styles kernel make math math.functions math.parser sequences
 strings xml.syntax ;
 IN: html.streams
@@ -33,15 +33,11 @@ TUPLE: html-sub-stream < html-writer style parent ;
 : href-link-tag ( xml style -- xml )
     href of [ simple-link ] when* ;
 
-: hex-color, ( color -- )
-    [ red>> ] [ green>> ] [ blue>> ] tri
-    [ 255 * round >integer >hex 2 CHAR: 0 pad-head % ] tri@ ;
-
 : fg-css, ( color -- )
-    "color: #" % hex-color, "; " % ;
+    "color: " % color>hex % "; " % ;
 
 : bg-css, ( color -- )
-    "background-color: #" % hex-color, "; " % ;
+    "background-color: " % color>hex % "; " % ;
 
 : style-css, ( flag -- )
     dup
@@ -95,7 +91,7 @@ M: html-span-stream dispose
     end-sub-stream format-html-span ;
 
 : border-css, ( border -- )
-    "border: 1px solid #" % hex-color, "; " % ;
+    "border: 1px solid " % color>hex % "; " % ;
 
 : (padding-css,) ( horizontal vertical -- )
     2dup = [