]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge up
authorerikc <erikcharlebois@gmail.com>
Sun, 31 Jan 2010 04:48:06 +0000 (20:48 -0800)
committererikc <erikcharlebois@gmail.com>
Sun, 31 Jan 2010 04:48:06 +0000 (20:48 -0800)
17 files changed:
basis/compiler/compiler.factor
basis/compiler/crossref/crossref.factor
basis/compiler/tree/propagation/propagation-tests.factor
basis/compiler/tree/propagation/transforms/transforms.factor
basis/grouping/grouping.factor
basis/images/images.factor
basis/stack-checker/dependencies/dependencies.factor
basis/tools/deploy/shaker/shaker.factor
core/classes/algebra/algebra.factor
core/math/integers/integers.factor
core/math/math-docs.factor
core/words/words-tests.factor
extra/benchmark/nsieve-bits/nsieve-bits.factor
extra/benchmark/nsieve/nsieve.factor
extra/images/atlas/atlas.factor [new file with mode: 0644]
extra/images/atlas/authors.txt [new file with mode: 0644]
extra/images/atlas/summary.txt [new file with mode: 0644]

index 0fb9231666f9d52f4fd258ad61d06714756aabef..94b927ca825ee020be5156719c7132e2baf274b3 100644 (file)
@@ -86,7 +86,7 @@ M: word combinator? inline? ;
     [
         dup crossref? [
             [ dependencies get generic-dependencies get compiled-xref ]
-            [ conditional-dependencies get save-conditional-dependencies ]
+            [ conditional-dependencies get set-dependency-checks ]
             bi
         ] [ drop ] if
     ] tri ;
@@ -184,8 +184,8 @@ M: optimizing-compiler update-call-sites ( class generic -- words )
     #! Words containing call sites with inferred type 'class'
     #! which inlined a method on 'generic'
     compiled-generic-usage swap '[
-        nip dup forgotten-class?
-        [ drop f ] [ _ classes-intersect? ] if
+        nip dup classoid?
+        [ _ classes-intersect? ] [ drop f ] if
     ] assoc-filter keys ;
 
 M: optimizing-compiler recompile ( words -- alist )
index 2e30e942d9391efecf9f70ef93cb820098df41ac..d6c000b28677142a038648e00e7bbfd38676cdaf 100644 (file)
@@ -55,7 +55,7 @@ compiled-generic-crossref [ H{ } clone ] initialize
 
 : store-dependencies ( word assoc -- )
     split-dependencies
-    "effect-dependencies" "definition-dependencies" "conditional-dependencies"
+    "effect-dependencies" "conditional-dependencies" "definition-dependencies"
     [ (store-dependencies) ] tri-curry@ tri-curry* tri ;
 
 : (compiled-xref) ( word dependencies generic-dependencies -- )
@@ -81,8 +81,8 @@ compiled-generic-crossref [ H{ } clone ] initialize
 
 : load-dependencies ( word -- assoc )
     [ "effect-dependencies" word-prop ]
-    [ "definition-dependencies" word-prop ]
-    [ "conditional-dependencies" word-prop ] tri
+    [ "conditional-dependencies" word-prop ]
+    [ "definition-dependencies" word-prop ] tri
     join-dependencies ;
 
 : (compiled-unxref) ( word dependencies variable -- )
@@ -96,8 +96,8 @@ compiled-generic-crossref [ H{ } clone ] initialize
         [ dup load-dependencies compiled-crossref (compiled-unxref) ]
         [ dup compiled-generic-uses compiled-generic-crossref (compiled-unxref) ]
         [ "effect-dependencies" remove-word-prop ]
-        [ "definition-dependencies" remove-word-prop ]
         [ "conditional-dependencies" remove-word-prop ]
+        [ "definition-dependencies" remove-word-prop ]
         [ "compiled-generic-uses" remove-word-prop ]
     } cleave ;
 
@@ -107,5 +107,5 @@ compiled-generic-crossref [ H{ } clone ] initialize
     [ compiled-generic-crossref get delete-at ]
     tri ;
 
-: save-conditional-dependencies ( word deps -- )
+: set-dependency-checks ( word deps -- )
     keys f like "dependency-checks" set-word-prop ;
index ad17ccc1c95f32e373ea069a72514c30950d407e..e2bfe587884d02bea894f1a2942f9573c94e1cfd 100644 (file)
@@ -8,7 +8,7 @@ layouts compiler.tree.propagation.info compiler.tree.def-use
 compiler.tree.debugger compiler.tree.checker slots.private words
 hashtables classes assocs locals specialized-arrays system
 sorting math.libm math.floats.private math.integers.private
-math.intervals quotations effects alien alien.data ;
+math.intervals quotations effects alien alien.data sets ;
 FROM: math => float ;
 SPECIALIZED-ARRAY: double
 SPECIALIZED-ARRAY: void*
@@ -952,3 +952,13 @@ M: tuple-with-read-only-slot clone
 
 ! Reduction
 [ 1 ] [ [ 4 <reversed> [ nth-unsafe ] [ ] unless ] final-info length ] unit-test
+
+! Optimization on bit?
+[ t ] [ [ 3 bit? ] { bit? fixnum-bit? } inlined? ] unit-test
+[ f ] [ [ 500 bit? ] { bit? fixnum-bit? } inlined? ] unit-test
+
+[ t ] [ [ { 1 } intersect ] { intersect } inlined? ] unit-test
+[ f ] [ [ { 1 } swap intersect ] { intersect } inlined? ] unit-test ! We could do this
+
+[ t ] [ [ { 1 } diff ] { diff } inlined? ] unit-test
+[ f ] [ [ { 1 } swap diff ] { diff } inlined? ] unit-test ! We could do this
index e95c6c4a4978b4304c013e064d262e7e07dbc88b..da3bd58f74da06478f1cfb24cadd54c8828b7ea7 100644 (file)
@@ -284,6 +284,15 @@ CONSTANT: lookup-table-at-max 256
 
 \ intersect [ intersect-quot ] 1 define-partial-eval
 
+: fixnum-bits ( -- n )
+    cell-bits tag-bits get - ;
+
+: bit-quot ( #call -- quot/f )
+    in-d>> second value-info interval>> 0 fixnum-bits [a,b] interval-subset?
+    [ [ >fixnum ] dip fixnum-bit? ] f ? ;
+
+\ bit? [ bit-quot ] "custom-inlining" set-word-prop
+
 ! Speeds up sum-file, sort and reverse-complement benchmarks by
 ! compiling decoder-readln better
 \ push [
index 8364144694d747ed9110f9d7b8c636f3c2e55aa0..4ee0d0c38519e9833db99f5745f7d032f9353a65 100644 (file)
@@ -6,35 +6,29 @@ IN: grouping
 
 <PRIVATE
 
-TUPLE: chunking-seq { seq read-only } { n read-only } ;
-
-: check-groups ( n -- n )
-    dup 0 <= [ "Invalid group count" throw ] when ; inline
-
-: new-groups ( seq n class -- groups )
-    [ check-groups ] dip boa ; inline
+MIXIN: chunking
+INSTANCE: chunking sequence
 
 GENERIC: group@ ( n groups -- from to seq )
 
-M: chunking-seq set-nth group@ <slice> 0 swap copy ;
-
-M: chunking-seq like drop { } like ; inline
+M: chunking set-nth group@ <slice> 0 swap copy ;
+M: chunking like drop { } like ; inline
 
 MIXIN: subseq-chunking
-
+INSTANCE: subseq-chunking chunking
 INSTANCE: subseq-chunking sequence
 
 M: subseq-chunking nth group@ subseq ; inline
 
 MIXIN: slice-chunking
-
+INSTANCE: slice-chunking chunking
 INSTANCE: slice-chunking sequence
 
 M: slice-chunking nth group@ <slice> ; inline
-
 M: slice-chunking nth-unsafe group@ slice boa ; inline
 
-TUPLE: abstract-groups < chunking-seq ;
+MIXIN: abstract-groups
+INSTANCE: abstract-groups sequence
 
 M: abstract-groups length
     [ seq>> length ] [ n>> ] bi [ + 1 - ] keep /i ; inline
@@ -45,7 +39,8 @@ M: abstract-groups set-length
 M: abstract-groups group@
     [ n>> [ * dup ] keep + ] [ seq>> ] bi [ length min ] keep ; inline
 
-TUPLE: abstract-clumps < chunking-seq ;
+MIXIN: abstract-clumps
+INSTANCE: abstract-clumps sequence
 
 M: abstract-clumps length
     [ seq>> length 1 + ] [ n>> ] bi [-] ; inline
@@ -56,36 +51,44 @@ M: abstract-clumps set-length
 M: abstract-clumps group@
     [ n>> over + ] [ seq>> ] bi ; inline
 
+TUPLE: chunking-seq { seq read-only } { n read-only } ;
+
+: check-groups ( n -- n )
+    dup 0 <= [ "Invalid group count" throw ] when ; inline
+
+: new-groups ( seq n class -- groups )
+    [ check-groups ] dip boa ; inline
+
 PRIVATE>
 
-TUPLE: groups < abstract-groups ;
+TUPLE: groups < chunking-seq ;
+INSTANCE: groups subseq-chunking
+INSTANCE: groups abstract-groups
 
 : <groups> ( seq n -- groups )
     groups new-groups ; inline
 
-INSTANCE: groups subseq-chunking
-
-TUPLE: sliced-groups < abstract-groups ;
+TUPLE: sliced-groups < chunking-seq ;
+INSTANCE: sliced-groups slice-chunking
+INSTANCE: sliced-groups abstract-groups
 
 : <sliced-groups> ( seq n -- groups )
     sliced-groups new-groups ; inline
 
-INSTANCE: sliced-groups slice-chunking
-
-TUPLE: clumps < abstract-clumps ;
+TUPLE: clumps < chunking-seq ;
+INSTANCE: clumps subseq-chunking
+INSTANCE: clumps abstract-clumps
 
 : <clumps> ( seq n -- clumps )
     clumps new-groups ; inline
 
-INSTANCE: clumps subseq-chunking
-
-TUPLE: sliced-clumps < abstract-clumps ;
+TUPLE: sliced-clumps < chunking-seq ;
+INSTANCE: sliced-clumps slice-chunking
+INSTANCE: sliced-clumps abstract-clumps
 
 : <sliced-clumps> ( seq n -- clumps )
     sliced-clumps new-groups ; inline
 
-INSTANCE: sliced-clumps slice-chunking
-
 : group ( seq n -- array ) <groups> { } like ;
 
 : clump ( seq n -- array ) <clumps> { } like ;
index 625627f337027307c47089b27866a04c863dd960..6cbcdb9508f7235f4294f5a3fc5e8f7ad0efe306 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2009 Doug Coleman, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: combinators kernel accessors sequences math arrays ;
+USING: combinators kernel locals accessors sequences math arrays ;
 IN: images
 
 SINGLETONS:
@@ -128,18 +128,31 @@ TUPLE: image dim component-order component-type upside-down? bitmap ;
 
 <PRIVATE
 
-: pixel@ ( x y image -- start end bitmap )
-    [ dim>> first * + ]
-    [ bytes-per-pixel [ * dup ] keep + ]
-    [ bitmap>> ] tri ;
+:: pixel@ ( x y w image -- start end bitmap )
+    image dim>> first y * x + :> start
+    start w [ image bytes-per-pixel * ] bi@ :> ( start' w' )
+    start'  start' w' +  image bitmap>> ; inline
 
 : set-subseq ( new-value from to victim -- )
     <slice> 0 swap copy ; inline
 
 PRIVATE>
 
+: pixel-row-at ( x y w image -- pixels )
+    pixel@ subseq ; inline
+
+: pixel-row-slice-at ( x y w image -- pixels )
+    pixel@ <slice> ; inline
+
+: set-pixel-row-at ( pixel x y w image -- )
+    pixel@ set-subseq ; inline
+
 : pixel-at ( x y image -- pixel )
-    pixel@ subseq ;
+    [ 1 ] dip pixel-row-at ; inline
+
+: pixel-slice-at ( x y image -- pixels )
+    [ 1 ] dip pixel-row-slice-at ; inline
 
 : set-pixel-at ( pixel x y image -- )
-    pixel@ set-subseq ;
+    [ 1 ] dip set-pixel-row-at ; inline
+
index 6fa2ae4eaba1ad0fc4095e0f45519ba924e0b615..d995354a52f41636026cc5a4b3723b9ced69e626 100644 (file)
@@ -1,7 +1,7 @@
 ! Copyright (C) 2009, 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: assocs accessors classes.algebra fry generic kernel math
-namespaces sequences words sets ;
+namespaces sequences words sets combinators.short-circuit ;
 FROM: classes.tuple.private => tuple-layout ;
 IN: stack-checker.dependencies
 
@@ -62,7 +62,11 @@ TUPLE: depends-on-class<= class1 class2 ;
     \ depends-on-class<= add-conditional-dependency ;
 
 M: depends-on-class<= satisfied?
-    [ class1>> ] [ class2>> ] bi class<= ;
+    {
+        [ class1>> classoid? ]
+        [ class2>> classoid? ]
+        [ [ class1>> ] [ class2>> ] bi class<= ]
+    } 1&& ;
 
 TUPLE: depends-on-classes-disjoint class1 class2 ;
 
@@ -70,7 +74,11 @@ TUPLE: depends-on-classes-disjoint class1 class2 ;
     \ depends-on-classes-disjoint add-conditional-dependency ;
 
 M: depends-on-classes-disjoint satisfied?
-    [ class1>> ] [ class2>> ] bi classes-intersect? not ;
+    {
+        [ class1>> classoid? ]
+        [ class2>> classoid? ]
+        [ [ class1>> ] [ class2>> ] bi classes-intersect? not ]
+    } 1&& ;
 
 TUPLE: depends-on-next-method class generic next-method ;
 
@@ -79,7 +87,10 @@ TUPLE: depends-on-next-method class generic next-method ;
     \ depends-on-next-method add-conditional-dependency ;
 
 M: depends-on-next-method satisfied?
-    [ [ class>> ] [ generic>> ] bi next-method ] [ next-method>> ] bi eq? ;
+    {
+        [ class>> classoid? ]
+        [ [ [ class>> ] [ generic>> ] bi next-method ] [ next-method>> ] bi eq? ]
+    } 1&& ;
 
 TUPLE: depends-on-method class generic method ;
 
@@ -88,7 +99,10 @@ TUPLE: depends-on-method class generic method ;
     \ depends-on-method add-conditional-dependency ;
 
 M: depends-on-method satisfied?
-    [ [ class>> ] [ generic>> ] bi method-for-class ] [ method>> ] bi eq? ;
+    {
+        [ class>> classoid? ]
+        [ [ [ class>> ] [ generic>> ] bi method-for-class ] [ method>> ] bi eq? ]
+    } 1&& ;
 
 TUPLE: depends-on-tuple-layout class layout ;
 
index c2db471a2320b68677b8daf15013b08d51f291a6..dfb5b7fa30d52b4793ee845a0ca4a73e316ee683 100755 (executable)
@@ -127,8 +127,10 @@ IN: tools.deploy.shaker
                 "coercer"
                 "combination"
                 "compiled-generic-uses"
-                "compiled-uses"
+                "effect-dependencies"
+                "definition-dependencies"
                 "conditional-dependencies"
+                "dependency-checks"
                 "constant"
                 "constraints"
                 "custom-inlining"
index f57c3de4dc22a867d2cc2c7d5188e810d68eb0e1..30697eb6a8661c09180275b0bfe208bcacb8c8d1 100644 (file)
@@ -40,12 +40,12 @@ M: object normalize-class ;
 
 PRIVATE>
 
-GENERIC: forgotten-class? ( obj -- ? )
+GENERIC: classoid? ( obj -- ? )
 
-M: word forgotten-class? "forgotten" word-prop ;
-M: anonymous-union forgotten-class? members>> [ forgotten-class? ] any? ;
-M: anonymous-intersection forgotten-class? participants>> [ forgotten-class? ] any? ;
-M: anonymous-complement forgotten-class? class>> forgotten-class? ;
+M: word classoid? class? ;
+M: anonymous-union classoid? members>> [ classoid? ] all? ;
+M: anonymous-intersection classoid? participants>> [ classoid? ] all? ;
+M: anonymous-complement classoid? class>> classoid? ;
 
 : class<= ( first second -- ? )
     class<=-cache get [ (class<=) ] 2cache ;
index e95c6d832b4591606a6bd75c8c84a5f4260950f7..5f461e22a3816ca25c2633422c4d06c90d17c505 100644 (file)
@@ -58,7 +58,10 @@ M: fixnum shift >fixnum fixnum-shift ; inline
 
 M: fixnum bitnot fixnum-bitnot ; inline
 
-M: fixnum bit? neg shift 1 bitand 0 > ; inline
+: fixnum-bit? ( n m -- b )
+    neg shift 1 bitand 0 > ; inline
+
+M: fixnum bit? fixnum-bit? ; inline
 
 : fixnum-log2 ( x -- n )
     0 swap [ dup 1 eq? ] [ [ 1 + ] [ 2/ ] bi* ] until drop ;
index 6af48d00de19270d6c53f050cfb066a769d8d752..1e107124a29d5c9b49d68ecc2f0fdeedeb418b27 100644 (file)
@@ -403,7 +403,7 @@ HELP: number
 
 HELP: next-power-of-2
 { $values { "m" "a non-negative integer" } { "n" "an integer" } }
-{ $description "Outputs the smallest power of 2 greater than " { $snippet "m" } ". The output value is always at least 1." } ;
+{ $description "Outputs the smallest power of 2 greater than " { $snippet "m" } ". The output value is always at least 2." } ;
 
 HELP: power-of-2?
 { $values { "n" integer } { "?" "a boolean" } }
index 4f30e9a89957a00f0da4ee17a5979588f1d3f10a..46b20bf2e608c89fc11c91130fa3a4caeeefca11 100644 (file)
@@ -122,8 +122,10 @@ DEFER: x
 [ { } ]
 [
     all-words [
-        "compiled-uses" word-prop 2 <groups>
-        keys [ "forgotten" word-prop ] filter
+        [ "effect-dependencies" word-prop ]
+        [ "definition-dependencies" word-prop ]
+        [ "conditional-dependencies" word-prop ] tri
+        3append [ "forgotten" word-prop ] filter
     ] map harvest
 ] unit-test
 
index 9ccc2d8616171bf851e298534d39dc7d7635b400..8d56bd935b1aa5d6c88386eabeb78fe5f667f736 100644 (file)
@@ -1,5 +1,5 @@
 USING: math math.parser sequences sequences.private kernel
-bit-arrays make io ;
+bit-arrays make io math.ranges multiline fry locals ;
 IN: benchmark.nsieve-bits
 
 : clear-flags ( step i seq -- )
@@ -13,23 +13,24 @@ IN: benchmark.nsieve-bits
     2dup length < [
         2dup nth-unsafe [
             over dup 2 * pick clear-flags
-            rot 1 + -rot ! increment count
+            [ 1 + ] 2dip ! increment count
         ] when [ 1 + ] dip (nsieve-bits)
     ] [
         2drop
     ] if ; inline recursive
 
 : nsieve-bits ( m -- count )
-    0 2 rot 1 + <bit-array> dup set-bits (nsieve-bits) ;
+    [ 0 2 ] dip 1 + <bit-array> dup set-bits (nsieve-bits) ;
 
 : nsieve-bits. ( m -- )
     [ "Primes up to " % dup # " " % nsieve-bits # ] "" make
-    print ;
+    print ; inline
 
 : nsieve-bits-main ( n -- )
-    dup 2^ 10000 * nsieve-bits.
-    dup 1 - 2^ 10000 * nsieve-bits.
-    2 - 2^ 10000 * nsieve-bits. ;
+    [ 2^ 10000 * nsieve-bits. ] 
+    [ 1 - 2^ 10000 * nsieve-bits. ]
+    [ 2 - 2^ 10000 * nsieve-bits. ]
+    tri ;
 
 : nsieve-bits-main* ( -- ) 11 nsieve-bits-main ;
 
index 646c98f3a4214f2da60b9e0b06fecb31676d0b7c..7c4a655e5984b242081aef1aeea3136a7e33cda0 100644 (file)
@@ -13,22 +13,23 @@ IN: benchmark.nsieve
     2dup length < [
         2dup nth-unsafe [
             over dup 2 * pick clear-flags
-            rot 1 + -rot ! increment count
+            [ 1 + ] 2dip ! increment count
         ] when [ 1 + ] dip (nsieve)
     ] [
         2drop
     ] if ; inline recursive
 
 : nsieve ( m -- count )
-    0 2 rot 1 + t <array> (nsieve) ;
+    [ 0 2 ] dip 1 + t <array> (nsieve) ;
 
 : nsieve. ( m -- )
     [ "Primes up to " % dup # " " % nsieve # ] "" make print ;
 
 : nsieve-main ( n -- )
-    dup 2^ 10000 * nsieve.
-    dup 1 - 2^ 10000 * nsieve.
-    2 - 2^ 10000 * nsieve. ;
+    [ 2^ 10000 * nsieve. ]
+    [ 1 - 2^ 10000 * nsieve. ]
+    [ 2 - 2^ 10000 * nsieve. ]
+    tri ;
 
 : nsieve-main* ( -- ) 9 nsieve-main ;
 
diff --git a/extra/images/atlas/atlas.factor b/extra/images/atlas/atlas.factor
new file mode 100644 (file)
index 0000000..aa0a69c
--- /dev/null
@@ -0,0 +1,107 @@
+! (c)2010 Joe Groff bsd license
+USING: accessors byte-arrays fry images kernel locals math
+math.functions math.order math.vectors namespaces sequences
+sorting ;
+IN: images.atlas
+
+! sort rects by height/width/whatever
+! use least power of two greater than k * greatest width for atlas width
+! pack stripes(y 0):
+!   place first rect at x 0
+!   place rects that fit in remaining stripe
+!   pack stripes(y + height)
+! if height > max height 
+
+TUPLE: image-placement
+    { image read-only }
+    loc ;
+
+CONSTANT: atlas-waste-factor 1.25
+CONSTANT: atlas-padding 1
+
+ERROR: atlas-image-formats-dont-match images ;
+
+<PRIVATE
+
+: width  ( dim -- width  ) first  atlas-padding + ; inline
+: height ( dim -- height ) second atlas-padding + ; inline
+: area   ( dim -- area   ) [ width ] [ height ] bi * ; inline
+
+:: (pack-stripe) ( image-placements atlas-width @y -- stripe-height/f )
+    0 :> @x!
+    f :> stripe-height!
+    image-placements [| ip |
+        ip loc>> [
+            ip image>> dim>> :> dim
+            stripe-height [ dim height stripe-height 0 or max stripe-height! ] unless
+            dim width :> w
+            atlas-width w @x + >= [
+                ip { @x @y } >>loc drop
+                @x w + @x!
+            ] when
+        ] unless
+    ] each
+    stripe-height ;
+
+:: (pack-images) ( images atlas-width sort-quot -- placements )
+    images sort-quot inv-sort-with [ f image-placement boa ] map :> image-placements
+    0 :> @y!
+    [ image-placements atlas-width @y (pack-stripe) dup ] [ @y + @y! ] while drop
+    image-placements ; inline
+
+: atlas-image-format ( image-placements -- component-order component-type upside-down? )
+    [ image>> ] map dup unclip '[ _
+        [ [ component-order>> ] bi@ = ]
+        [ [ component-type>>  ] bi@ = ]
+        [ [ upside-down?>>    ] bi@ = ] 2tri and and
+    ] all?
+    [ first [ component-order>> ] [ component-type>> ] [ upside-down?>> ] tri ]
+    [ atlas-image-formats-dont-match ] if ; inline
+
+: atlas-dim ( image-placements -- dim )
+    [ [ loc>> ] [ image>> dim>> ] bi v+ atlas-padding v+n ] [ vmax ] map-reduce
+    [ next-power-of-2 ] map ; inline
+
+:: <atlas-image> ( image-placements component-order component-type upside-down? -- atlas )
+    image-placements atlas-dim :> dim
+    <image>
+        dim >>dim
+        component-order >>component-order
+        component-type >>component-type
+        upside-down? >>upside-down?
+        dim product component-order component-type (bytes-per-pixel) * <byte-array> >>bitmap ; inline
+
+:: copy-image-into-atlas ( image-placement atlas -- )
+    image-placement image>> :> image
+    image dim>> first2 :> ( w h )
+    image-placement loc>> first2 :> ( x y )
+
+    h iota [| row |
+        0  row      w  image pixel-row-slice-at
+        x  y row +  w  atlas set-pixel-row-at
+    ] each ; inline
+
+: copy-images-into-atlas ( image-placements atlas -- )
+    '[ _ copy-image-into-atlas ] each ; inline
+
+PRIVATE>
+
+: (guess-atlas-dim) ( images -- width )
+    [ dim>> area ] [ + ] map-reduce sqrt
+    atlas-waste-factor *
+    .5 + >integer ;
+
+: guess-atlas-dim ( images -- width )
+    [ (guess-atlas-dim) ] [ [ dim>> width ] [ max ] map-reduce ] bi max next-power-of-2 ;
+
+: pack-images ( images atlas-width -- placements )
+    [ dim>> second ] (pack-images) ;
+
+: pack-atlas ( images -- image-placements )
+    dup guess-atlas-dim pack-images ;
+
+: (make-atlas) ( image-placements -- image )
+    dup dup atlas-image-format <atlas-image> [ copy-images-into-atlas ] keep ;
+
+: make-atlas ( images -- image-placements atlas-image )
+    pack-atlas dup (make-atlas) ;
diff --git a/extra/images/atlas/authors.txt b/extra/images/atlas/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/images/atlas/summary.txt b/extra/images/atlas/summary.txt
new file mode 100644 (file)
index 0000000..eb1adcd
--- /dev/null
@@ -0,0 +1 @@
+Tool for generating an atlas image from an array of images