home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / gprocs / mirror.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  67 lines

  1. ############################################################################
  2. #
  3. #    File:     mirror.icn
  4. #
  5. #    Subject:  Procedure to mirror tile
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     November 15, 1997
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  mirror(win)    mirrors win using p2mm symmetry and returns the result as a
  18. #        hidden window.
  19. #
  20. ############################################################################
  21. #
  22. #  Requires:  Version 9 graphics
  23. #
  24. ############################################################################
  25. #
  26. #  Links:  wopen
  27. #
  28. ############################################################################
  29.  
  30. link wopen
  31.  
  32. procedure mirror(win, x, y, w, h)    # mirror with p2mm symmetry
  33.    local width, height, sym, x1, y1
  34.  
  35.    /win := &window
  36.    /x := 0
  37.    /y := 0
  38.    /w := WAttrib(win, "width")
  39.    /h := WAttrib(win, "height")
  40.  
  41.    if w < 0 then {
  42.       w := -w
  43.       x -:= w
  44.       }
  45.  
  46.    if h < 0 then {
  47.       h := -h
  48.       y -:= h
  49.       }
  50.  
  51.    width := 2 * w
  52.    height := 2 * h
  53.  
  54.    sym := WOpen("canvas=hidden", "size=" || width || "," || height) | fail
  55.  
  56.    CopyArea(win, sym, x, y, w, h)
  57.  
  58.    every x := 0 to w - 1 do 
  59.       CopyArea(sym, sym, x, 0, 1, h, width - x - 1, 0)
  60.  
  61.    every y := 0 to h - 1 do
  62.       CopyArea(sym, sym, 0, y, width, 1, 0, height - y - 1)
  63.  
  64.    return sym
  65.  
  66. end
  67.