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