/unmaintained/images/processing/rotation/rotation-tests.factor

http://github.com/abeaumont/factor · Factor · 71 lines · 54 code · 15 blank · 2 comment · 11 complexity · 697f22e277a75675cf61e2054a67dcef MD5 · raw file

  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. : first-row ( seq^2 -- seq ) first ;
  8. : first-col ( seq^2 -- item ) harvest [ first ] map ;
  9. : last-row ( seq^2 -- item ) last ;
  10. : last-col ( seq^2 -- item ) harvest [ last ] map ;
  11. : end-of-first-row ( seq^2 -- item ) first-row last ;
  12. : first-of-first-row ( seq^2 -- item ) first-row first ;
  13. : end-of-last-row ( seq^2 -- item ) last-row last ;
  14. : first-of-last-row ( seq^2 -- item ) last-row first ;
  15. <<
  16. : clone-image ( image -- new-image )
  17. clone [ clone ] change-bitmap ;
  18. >>
  19. : pasted-image ( -- image )
  20. "vocab:images/processing/rotation/test-bitmaps/PastedImage.bmp"
  21. load-image clone-image ;
  22. : pasted-image90 ( -- image )
  23. "vocab:images/processing/rotation/test-bitmaps/PastedImage90.bmp"
  24. load-image clone-image ;
  25. : lake-image ( -- image )
  26. "vocab:images/processing/rotation/test-bitmaps/lake.bmp"
  27. load-image clone-image image>pixel-rows ;
  28. [ t ] [ pasted-image dup clone-image 4 [ 90 rotate ] times = ] unit-test
  29. [ t ] [ pasted-image dup clone-image 2 [ 180 rotate ] times = ] unit-test
  30. [ t ] [ pasted-image dup clone-image 270 rotate 90 rotate = ] unit-test
  31. [ t ] [
  32. pasted-image dup clone-image dup { 90 180 90 } [ rotate drop ] with each =
  33. ] unit-test
  34. [ t ] [
  35. pasted-image 90 rotate
  36. pasted-image90 =
  37. ] unit-test
  38. [ t ] [
  39. "vocab:images/processing/rotation/test-bitmaps/small.bmp"
  40. load-image 90 rotate
  41. "vocab:images/processing/rotation/test-bitmaps/small-rotated.bmp"
  42. load-image =
  43. ] unit-test
  44. [ t ] [
  45. lake-image
  46. [ first-of-first-row ]
  47. [ 90 (rotate) end-of-first-row ] bi =
  48. ] unit-test
  49. [ t ]
  50. [ lake-image [ first-row ] [ 90 (rotate) last-col ] bi = ] unit-test
  51. [ t ]
  52. [ lake-image [ last-col ] [ 90 (rotate) last-row reverse ] bi = ] unit-test
  53. [ t ]
  54. [ lake-image [ last-row ] [ 90 (rotate) first-col ] bi = ] unit-test
  55. [ t ]
  56. [ lake-image [ first-col ] [ 90 (rotate) first-row reverse ] bi = ] unit-test