+++ /dev/null
-Slava Pestov
\ No newline at end of file
+++ /dev/null
-USING: images accessors kernel tools.test literals math.ranges
-byte-arrays ;
-IN: images.tesselation
-
-! Check an invariant we depend on
-[ t ] [
- <image> B{ 1 2 3 } >>bitmap dup clone [ bitmap>> ] bi@ eq?
-] unit-test
-
-[
- {
- {
- T{ image f { 2 2 } L ubyte-components f f B{ 1 2 5 6 } }
- T{ image f { 2 2 } L ubyte-components f f B{ 3 4 7 8 } }
- }
- {
- T{ image f { 2 2 } L ubyte-components f f B{ 9 10 13 14 } }
- T{ image f { 2 2 } L ubyte-components f f B{ 11 12 15 16 } }
- }
- }
-] [
- <image>
- 1 16 [a,b] >byte-array >>bitmap
- { 4 4 } >>dim
- L >>component-order
- ubyte-components >>component-type
- { 2 2 } tesselate
-] unit-test
-
-[
- {
- {
- T{ image f { 2 2 } L ubyte-components f f B{ 1 2 4 5 } }
- T{ image f { 1 2 } L ubyte-components f f B{ 3 6 } }
- }
- {
- T{ image f { 2 1 } L ubyte-components f f B{ 7 8 } }
- T{ image f { 1 1 } L ubyte-components f f B{ 9 } }
- }
- }
-] [
- <image>
- 1 9 [a,b] >byte-array >>bitmap
- { 3 3 } >>dim
- L >>component-order
- ubyte-components >>component-type
- { 2 2 } tesselate
-] unit-test
+++ /dev/null
-! Copyright (C) 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-USING: sequences kernel math grouping fry columns locals accessors
-images math.vectors arrays ;
-IN: images.tesselation
-
-: group-rows ( bitmap bitmap-dim -- rows )
- first <sliced-groups> ; inline
-
-: tesselate-rows ( bitmap-rows tess-dim -- bitmaps )
- second <sliced-groups> ; inline
-
-: tesselate-columns ( bitmap-rows tess-dim -- bitmaps )
- first '[ _ <sliced-groups> ] map flip ; inline
-
-: tesselate-bitmap ( bitmap bitmap-dim tess-dim -- bitmap-grid )
- [ group-rows ] dip
- [ tesselate-rows ] keep
- '[ _ tesselate-columns ] map ;
-
-: tile-width ( tile-bitmap original-image -- width )
- [ first length ] [ bytes-per-pixel ] bi* /i ;
-
-: <tile-image> ( tile-bitmap original-image -- tile-image )
- clone
- swap
- [ concat >>bitmap ]
- [ [ over tile-width ] [ length ] bi 2array >>dim ] bi ;
-
-:: tesselate ( image tess-dim -- image-grid )
- image bytes-per-pixel :> bpp
- image dim>> { bpp 1 } v* :> image-dim'
- tess-dim { bpp 1 } v* :> tess-dim'
- image bitmap>> image-dim' tess-dim' tesselate-bitmap
- [ [ image <tile-image> ] map ] map ;
--- /dev/null
+Slava Pestov
\ No newline at end of file
--- /dev/null
+USING: images accessors kernel tools.test literals math.ranges
+byte-arrays ;
+IN: images.tessellation
+
+! Check an invariant we depend on
+[ t ] [
+ <image> B{ 1 2 3 } >>bitmap dup clone [ bitmap>> ] bi@ eq?
+] unit-test
+
+[
+ {
+ {
+ T{ image f { 2 2 } L ubyte-components f f B{ 1 2 5 6 } }
+ T{ image f { 2 2 } L ubyte-components f f B{ 3 4 7 8 } }
+ }
+ {
+ T{ image f { 2 2 } L ubyte-components f f B{ 9 10 13 14 } }
+ T{ image f { 2 2 } L ubyte-components f f B{ 11 12 15 16 } }
+ }
+ }
+] [
+ <image>
+ 1 16 [a,b] >byte-array >>bitmap
+ { 4 4 } >>dim
+ L >>component-order
+ ubyte-components >>component-type
+ { 2 2 } tesselate
+] unit-test
+
+[
+ {
+ {
+ T{ image f { 2 2 } L ubyte-components f f B{ 1 2 4 5 } }
+ T{ image f { 1 2 } L ubyte-components f f B{ 3 6 } }
+ }
+ {
+ T{ image f { 2 1 } L ubyte-components f f B{ 7 8 } }
+ T{ image f { 1 1 } L ubyte-components f f B{ 9 } }
+ }
+ }
+] [
+ <image>
+ 1 9 [a,b] >byte-array >>bitmap
+ { 3 3 } >>dim
+ L >>component-order
+ ubyte-components >>component-type
+ { 2 2 } tesselate
+] unit-test
--- /dev/null
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: sequences kernel math grouping fry columns locals accessors
+images math.vectors arrays ;
+IN: images.tessellation
+
+: group-rows ( bitmap bitmap-dim -- rows )
+ first <sliced-groups> ; inline
+
+: tesselate-rows ( bitmap-rows tess-dim -- bitmaps )
+ second <sliced-groups> ; inline
+
+: tesselate-columns ( bitmap-rows tess-dim -- bitmaps )
+ first '[ _ <sliced-groups> ] map flip ; inline
+
+: tesselate-bitmap ( bitmap bitmap-dim tess-dim -- bitmap-grid )
+ [ group-rows ] dip
+ [ tesselate-rows ] keep
+ '[ _ tesselate-columns ] map ;
+
+: tile-width ( tile-bitmap original-image -- width )
+ [ first length ] [ bytes-per-pixel ] bi* /i ;
+
+: <tile-image> ( tile-bitmap original-image -- tile-image )
+ clone
+ swap
+ [ concat >>bitmap ]
+ [ [ over tile-width ] [ length ] bi 2array >>dim ] bi ;
+
+:: tesselate ( image tess-dim -- image-grid )
+ image bytes-per-pixel :> bpp
+ image dim>> { bpp 1 } v* :> image-dim'
+ tess-dim { bpp 1 } v* :> tess-dim'
+ image bitmap>> image-dim' tess-dim' tesselate-bitmap
+ [ [ image <tile-image> ] map ] map ;
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.data assocs cache colors.constants
destructors kernel opengl opengl.gl opengl.capabilities
-combinators images images.tesselation grouping sequences math
+combinators images images.tessellation grouping sequences math
math.vectors generalizations fry arrays namespaces system locals
literals specialized-arrays ;
FROM: alien.c-types => int float ;