! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs combinators destructors fry html io
io.backend io.pathnames io.styles kernel macros make math
-math.order math.parser namespaces sequences strings words
-splitting xml xml.syntax ;
+math.functions math.order math.parser namespaces sequences
+strings words splitting xml xml.syntax ;
IN: html.streams
GENERIC: url-of ( object -- url )
: hex-color, ( color -- )
[ red>> ] [ green>> ] [ blue>> ] tri
- [ 255 * >integer >hex 2 CHAR: 0 pad-head % ] tri@ ;
+ [ 255 * round >integer >hex 2 CHAR: 0 pad-head % ] tri@ ;
: fg-css, ( color -- )
"color: #" % hex-color, "; " % ;
! See http://factorcode.org/license.txt for BSD license.
USING: alien.c-types alien.syntax classes.struct colors
io.encodings.utf16n io.encodings.utf8 kernel math math.bitwise
-math.vectors sequences ;
+math.functions math.vectors sequences ;
FROM: alien.c-types => float short ;
IN: windows.types
[ -16 shift 0xff bitand ] tri ;
: color>RGB ( color -- COLORREF )
- >rgba-components drop [ 255 * >integer ] tri@ RGB ;
+ >rgba-components drop [ 255 round * >integer ] tri@ RGB ;
: RGB>color ( COLORREF -- color )
- >RGB< [ 1/255. * >float ] tri@ 1.0 <rgba> ;
+ >RGB< [ 255 /f ] tri@ 1.0 <rgba> ;
STRUCT: TEXTMETRICW
{ tmHeight LONG }
USING: accessors alien.c-types alien.data arrays assocs
byte-arrays cache classes.struct colors combinators destructors
fonts images init io.encodings.string io.encodings.utf16n kernel
-literals locals math math.bitwise namespaces sequences
-specialized-arrays windows.errors windows.fonts windows.gdi32
-windows.offscreen windows.ole32 windows.types windows.usp10 ;
+literals locals math math.bitwise math.functions namespaces
+sequences specialized-arrays windows.errors windows.fonts
+windows.gdi32 windows.offscreen windows.ole32 windows.types
+windows.usp10 ;
SPECIALIZED-ARRAY: uint32_t
IN: windows.uniscribe
! transparency.
:: color-to-alpha ( image color -- image' )
color >rgba-components :> alpha
- [ 255 * >integer ] tri@ 3byte-array uint32_t deref 24 bits :> rgb
+ [ 255 * round >integer ] tri@ 3byte-array uint32_t deref 24 bits :> rgb
image bitmap>> uint32_t cast-array
alpha 1 <
[ [ 0xff bitand alpha * >integer 24 shift rgb bitor ] map! ]
! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors colors combinators combinators.smart formatting
-kernel literals math models sorting.human sorting.slots strings ui
-ui.gadgets.scrollers ui.gadgets.search-tables ui.gadgets.tables
-;
+kernel literals math math.functions models sorting.human
+sorting.slots strings ui ui.gadgets.scrollers
+ui.gadgets.search-tables ui.gadgets.tables ;
IN: color-table
! ui.gadgets.tables demo
: rgba>hex ( rgba -- hex )
[ red>> ] [ green>> ] [ blue>> ] tri
- [ 255 * >integer ] tri@ "%02X%02X%02X" sprintf ;
+ [ 255 * round >integer ] tri@ "%02X%02X%02X" sprintf ;
PRIVATE>
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
: rgba>hex ( rgba -- hex )
[ red>> ] [ green>> ] [ blue>> ] tri
- [ 255 * >integer ] tri@ "%02X%02X%02X" sprintf ;
+ [ 255 * round >integer ] tri@ "%02X%02X%02X" sprintf ;
: chart>url ( chart -- url )
[ URL" http://chart.googleapis.com/chart" clone ] dip {
USING: accessors colors combinators endian generalizations io
io.encodings.binary io.files io.streams.byte-array kernel math
-math.bitwise namespaces sequences ;
+math.bitwise math.functions namespaces sequences ;
IN: tinyvg
[ read1 255 /f ] 4 call-n <rgba> ;
: write-rgba-8888 ( rgba -- )
- >rgba-components [ 255 * >integer write1 ] 4 napply ;
+ >rgba-components [ 255 * round >integer write1 ] 4 napply ;
: read-rgb-565 ( -- rgba )
2 read le>