]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/google/charts/charts.factor
colors: using 255 * round >integer for hex conversion
[factor.git] / extra / google / charts / charts.factor
index d97a97bceb1ffaf1e620c01dd6abed32feda0016..02d00f624f5ef055d3a0baad95facffd7a4ac791 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2011 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors arrays assocs colors.hex combinators formatting
+USING: accessors arrays assocs combinators formatting
 http.client images.http images.loader images.loader.private
-images.viewer kernel math math.order present sequences splitting
-urls ;
+images.viewer kernel math math.functions math.order present
+sequences splitting urls ;
 
 IN: google.charts
 
@@ -70,8 +70,12 @@ PRIVATE>
 
 <PRIVATE
 
+: rgba>hex ( rgba -- hex )
+    [ red>> ] [ green>> ] [ blue>> ] tri
+    [ 255 * round >integer ] tri@ "%02X%02X%02X" sprintf ;
+
 : chart>url ( chart -- url )
-    [ URL" http://chart.googleapis.com/chart" ] dip {
+    [ URL" http://chart.googleapis.com/chart" clone ] dip {
         [ type>> "cht" set-query-param ]
         [
             [ width>> ] [ height>> ] bi 2dup and [