]> gitweb.factorcode.org Git - factor.git/commitdiff
Move colors to basis
authorEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Thu, 7 Aug 2008 20:46:11 +0000 (15:46 -0500)
committerEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Thu, 7 Aug 2008 20:46:11 +0000 (15:46 -0500)
basis/colors/authors.txt [new file with mode: 0644]
basis/colors/colors.factor [new file with mode: 0644]
basis/colors/hsv/authors.txt [new file with mode: 0755]
basis/colors/hsv/hsv.factor [new file with mode: 0644]
extra/colors/authors.txt [deleted file]
extra/colors/colors.factor [deleted file]
extra/colors/hsv/authors.txt [deleted file]
extra/colors/hsv/hsv.factor [deleted file]

diff --git a/basis/colors/authors.txt b/basis/colors/authors.txt
new file mode 100644 (file)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/colors/colors.factor b/basis/colors/colors.factor
new file mode 100644 (file)
index 0000000..77a1f46
--- /dev/null
@@ -0,0 +1,48 @@
+! Copyright (C) 2003, 2007, 2008 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+
+USING: kernel combinators sequences arrays classes.tuple accessors colors.hsv ;
+
+IN: colors
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+TUPLE: color ;
+
+TUPLE: rgba < color red green blue alpha ;
+
+TUPLE: hsva < color hue saturation value alpha ;
+
+TUPLE: gray < color gray alpha ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+GENERIC: >rgba ( object -- rgba )
+
+M: rgba >rgba ( rgba -- rgba ) ;
+
+M: hsva >rgba ( hsva -- rgba )
+  { [ hue>> ] [ saturation>> ] [ value>> ] [ alpha>> ] } cleave 4array
+  [ hsv>rgb ] [ peek ] bi suffix first4 rgba boa ;
+
+M: gray >rgba ( gray -- rgba ) [ gray>> dup dup ] [ alpha>> ] bi rgba boa ;
+
+M: color red>>   ( color -- red   ) >rgba red>>   ;
+M: color green>> ( color -- green ) >rgba green>> ;
+M: color blue>>  ( color -- blue  ) >rgba blue>>  ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: black        T{ rgba f 0.0   0.0   0.0   1.0  } ;
+: blue         T{ rgba f 0.0   0.0   1.0   1.0  } ;
+: cyan         T{ rgba f 0     0.941 0.941 1    } ;
+: gray         T{ rgba f 0.6   0.6   0.6   1.0  } ;
+: green        T{ rgba f 0.0   1.0   0.0   1.0  } ;
+: light-gray   T{ rgba f 0.95  0.95  0.95  0.95 } ;
+: light-purple T{ rgba f 0.8   0.8   1.0   1.0  } ;
+: magenta      T{ rgba f 0.941 0     0.941 1    } ;
+: orange       T{ rgba f 0.941 0.627 0     1    } ;
+: purple       T{ rgba f 0.627 0     0.941 1    } ;
+: red          T{ rgba f 1.0   0.0   0.0   1.0  } ;
+: white        T{ rgba f 1.0   1.0   1.0   1.0  } ;
+: yellow       T{ rgba f 1.0   1.0   0.0   1.0  } ;
diff --git a/basis/colors/hsv/authors.txt b/basis/colors/hsv/authors.txt
new file mode 100755 (executable)
index 0000000..1901f27
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
diff --git a/basis/colors/hsv/hsv.factor b/basis/colors/hsv/hsv.factor
new file mode 100644 (file)
index 0000000..dd28118
--- /dev/null
@@ -0,0 +1,41 @@
+! Copyright (C) 2007 Eduardo Cavazos
+! See http://factorcode.org/license.txt for BSD license.
+
+USING: kernel combinators arrays sequences math math.functions ;
+
+IN: colors.hsv
+
+<PRIVATE
+
+: H ( hsv -- H ) first ;
+
+: S ( hsv -- S ) second ;
+
+: V ( hsv -- V ) third ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: Hi ( hsv -- Hi ) H 60 / floor 6 mod ;
+
+: f ( hsv -- f ) [ H 60 / ] [ Hi ] bi - ;
+
+: p ( hsv -- p ) [ S 1 swap - ] [ V ] bi * ;
+
+: q ( hsv -- q ) [ [ f ] [ S ] bi * 1 swap - ] [ V ] bi * ;
+
+: t ( hsv -- t ) [ [ f 1 swap - ] [ S ] bi * 1 swap - ] [ V ] bi * ;
+
+PRIVATE>
+
+! h [0,360)
+! s [0,1]
+! v [0,1]
+
+: hsv>rgb ( hsv -- rgb )
+dup Hi
+{ { 0 [ [ V ] [ t ] [ p ] tri ] }
+  { 1 [ [ q ] [ V ] [ p ] tri ] }
+  { 2 [ [ p ] [ V ] [ t ] tri ] }
+  { 3 [ [ p ] [ q ] [ V ] tri ] }
+  { 4 [ [ t ] [ p ] [ V ] tri ] }
+  { 5 [ [ V ] [ p ] [ q ] tri ] } } case 3array ;
diff --git a/extra/colors/authors.txt b/extra/colors/authors.txt
deleted file mode 100644 (file)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/colors/colors.factor b/extra/colors/colors.factor
deleted file mode 100644 (file)
index 77a1f46..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-! Copyright (C) 2003, 2007, 2008 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-
-USING: kernel combinators sequences arrays classes.tuple accessors colors.hsv ;
-
-IN: colors
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-TUPLE: color ;
-
-TUPLE: rgba < color red green blue alpha ;
-
-TUPLE: hsva < color hue saturation value alpha ;
-
-TUPLE: gray < color gray alpha ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-GENERIC: >rgba ( object -- rgba )
-
-M: rgba >rgba ( rgba -- rgba ) ;
-
-M: hsva >rgba ( hsva -- rgba )
-  { [ hue>> ] [ saturation>> ] [ value>> ] [ alpha>> ] } cleave 4array
-  [ hsv>rgb ] [ peek ] bi suffix first4 rgba boa ;
-
-M: gray >rgba ( gray -- rgba ) [ gray>> dup dup ] [ alpha>> ] bi rgba boa ;
-
-M: color red>>   ( color -- red   ) >rgba red>>   ;
-M: color green>> ( color -- green ) >rgba green>> ;
-M: color blue>>  ( color -- blue  ) >rgba blue>>  ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: black        T{ rgba f 0.0   0.0   0.0   1.0  } ;
-: blue         T{ rgba f 0.0   0.0   1.0   1.0  } ;
-: cyan         T{ rgba f 0     0.941 0.941 1    } ;
-: gray         T{ rgba f 0.6   0.6   0.6   1.0  } ;
-: green        T{ rgba f 0.0   1.0   0.0   1.0  } ;
-: light-gray   T{ rgba f 0.95  0.95  0.95  0.95 } ;
-: light-purple T{ rgba f 0.8   0.8   1.0   1.0  } ;
-: magenta      T{ rgba f 0.941 0     0.941 1    } ;
-: orange       T{ rgba f 0.941 0.627 0     1    } ;
-: purple       T{ rgba f 0.627 0     0.941 1    } ;
-: red          T{ rgba f 1.0   0.0   0.0   1.0  } ;
-: white        T{ rgba f 1.0   1.0   1.0   1.0  } ;
-: yellow       T{ rgba f 1.0   1.0   0.0   1.0  } ;
diff --git a/extra/colors/hsv/authors.txt b/extra/colors/hsv/authors.txt
deleted file mode 100755 (executable)
index 1901f27..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Slava Pestov
diff --git a/extra/colors/hsv/hsv.factor b/extra/colors/hsv/hsv.factor
deleted file mode 100644 (file)
index dd28118..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-! Copyright (C) 2007 Eduardo Cavazos
-! See http://factorcode.org/license.txt for BSD license.
-
-USING: kernel combinators arrays sequences math math.functions ;
-
-IN: colors.hsv
-
-<PRIVATE
-
-: H ( hsv -- H ) first ;
-
-: S ( hsv -- S ) second ;
-
-: V ( hsv -- V ) third ;
-
-! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-: Hi ( hsv -- Hi ) H 60 / floor 6 mod ;
-
-: f ( hsv -- f ) [ H 60 / ] [ Hi ] bi - ;
-
-: p ( hsv -- p ) [ S 1 swap - ] [ V ] bi * ;
-
-: q ( hsv -- q ) [ [ f ] [ S ] bi * 1 swap - ] [ V ] bi * ;
-
-: t ( hsv -- t ) [ [ f 1 swap - ] [ S ] bi * 1 swap - ] [ V ] bi * ;
-
-PRIVATE>
-
-! h [0,360)
-! s [0,1]
-! v [0,1]
-
-: hsv>rgb ( hsv -- rgb )
-dup Hi
-{ { 0 [ [ V ] [ t ] [ p ] tri ] }
-  { 1 [ [ q ] [ V ] [ p ] tri ] }
-  { 2 [ [ p ] [ V ] [ t ] tri ] }
-  { 3 [ [ p ] [ q ] [ V ] tri ] }
-  { 4 [ [ t ] [ p ] [ V ] tri ] }
-  { 5 [ [ V ] [ p ] [ q ] tri ] } } case 3array ;