]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/images/processing/rotation/rotation-tests.factor
8f65362fdfbc2ef9c5b2c875a6748ac113aac79e
[factor.git] / unmaintained / images / processing / rotation / rotation-tests.factor
1 ! Copyright (C) 2009 Kobi Lurie, Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors fry images.loader
4 images.processing.rotation kernel literals math sequences
5 tools.test images.processing.rotation.private ;
6 IN: images.processing.rotation.tests
7
8 : first-row ( seq^2 -- seq ) first ;
9 : first-col ( seq^2 -- item ) harvest [ first ] map ;
10 : last-row ( seq^2 -- item ) last ;
11 : last-col ( seq^2 -- item ) harvest [ last ] map ;
12 : end-of-first-row ( seq^2 -- item ) first-row last ;
13 : first-of-first-row ( seq^2 -- item ) first-row first ;
14 : end-of-last-row ( seq^2 -- item ) last-row last ;
15 : first-of-last-row ( seq^2 -- item ) last-row first ;
16
17 <<
18
19 : clone-image ( image -- new-image )
20     clone [ clone ] change-bitmap ;
21
22 >>
23
24 : pasted-image ( -- image )
25     "vocab:images/processing/rotation/test-bitmaps/PastedImage.bmp"
26     load-image clone-image ;
27
28 : pasted-image90 ( -- image )
29     "vocab:images/processing/rotation/test-bitmaps/PastedImage90.bmp"
30     load-image clone-image ;
31
32 : lake-image ( -- image )
33     "vocab:images/processing/rotation/test-bitmaps/lake.bmp"
34     load-image clone-image image>pixel-rows ;
35
36 [ t ] [ pasted-image dup clone-image 4 [ 90 rotate ] times = ] unit-test
37 [ t ] [ pasted-image dup clone-image 2 [ 180 rotate ] times = ] unit-test
38 [ t ] [ pasted-image dup clone-image 270 rotate 90 rotate = ] unit-test
39 [ t ] [
40     pasted-image dup clone-image dup { 90 180 90 } [ rotate drop ] with each =
41 ] unit-test
42
43 [ t ] [
44     pasted-image 90 rotate
45     pasted-image90 = 
46 ] unit-test
47
48 [ t ] [
49     "vocab:images/processing/rotation/test-bitmaps/small.bmp"
50     load-image 90 rotate 
51     "vocab:images/processing/rotation/test-bitmaps/small-rotated.bmp"
52     load-image =
53 ] unit-test
54     
55 [ t ] [
56     lake-image
57     [ first-of-first-row ]
58     [ 90 (rotate) end-of-first-row ] bi =
59 ] unit-test
60
61 [ t ]
62 [ lake-image [ first-row ] [ 90 (rotate) last-col ] bi = ] unit-test
63
64 [ t ]
65 [ lake-image [ last-col ] [ 90 (rotate) last-row reverse ] bi = ] unit-test
66
67 [ t ]
68 [ lake-image [ last-row ] [ 90 (rotate) first-col ] bi = ] unit-test
69
70 [ t ]
71 [ lake-image [ first-col ] [ 90 (rotate) first-row reverse ] bi = ] unit-test