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 / gprogs / striper.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  88 lines

  1. ############################################################################
  2. #
  3. #    File:     striper.icn
  4. #
  5. #    Subject:  Program to make striped pattern from image edge
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     March 14, 1995
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program takes the left column or top row of pixels of an image
  18. #  and creates a 1 x n or n x 1 image file from it.  The result, when
  19. #  tiled, is a striped pattern.
  20. #
  21. #  This program is useful for creating regular striped patterns from
  22. #  scans.
  23. #
  24. #  The following options are supported:
  25. #
  26. #    -d s    stripe direction:
  27. #           "h"    horizontal (the default)
  28. #           "v"    vertical
  29. #           "b"    both horizontal and vertical
  30. #    -p s    prefix for GIF file names, default "stripes_"
  31. #    -w i    width of swatch, default 1
  32. #    -x i    x offset, default 0
  33. #    -y i    y offset, default 0
  34. #
  35. ############################################################################
  36. #
  37. #  Requires:  Version 9 graphics
  38. #
  39. ############################################################################
  40. #
  41. #  Links:  options, wopen
  42. #
  43. ############################################################################
  44.  
  45. link options
  46. link wopen
  47.  
  48. procedure main(args)
  49.    local file, hidden, count, prefix, opts, w, h, v, x, y
  50.  
  51.    opts := options(args, "d:w+p:x+y+")
  52.    prefix := \opts["p"] | "stripes_"
  53.    w := \opts["w"] | 1
  54.    x := \opts["x"] | 0
  55.    y := \opts["y"] | 0
  56.    case opts["d"] of {
  57.       "h":   h := 1
  58.       "v":   v := 1
  59.       "b":   {
  60.          h := 1
  61.          v := 1
  62.          }
  63.       &null: h := 1
  64.       default:  stop("Invalid direcTion specification")
  65.       }
  66.  
  67.    count := 0
  68.  
  69.    every file := !args do {
  70.       hidden := WOpen("canvas=hidden", "image=" || file) | {
  71.          write(&errout, "*** cannot open ", file)
  72.          next
  73.          }
  74.       if \h then {
  75.          WriteImage(hidden, prefix || right(count +:= 1, 3, "0") || ".gif",
  76.             x, 0, w, WAttrib(hidden, "height")) |
  77.                write(&errout, "*** cannot write image file")
  78.          }
  79.       if \v then {
  80.          WriteImage(hidden, prefix || right(count +:= 1, 3, "0") || ".gif",
  81.             0, y, WAttrib(hidden, "width"), w) |
  82.                write(&errout, "*** cannot write image file")
  83.          }
  84.       WClose(hidden)
  85.       }
  86.  
  87. end
  88.