summaryrefslogtreecommitdiff
path: root/ipl/gprocs/wipe.icn
blob: 8f2d8665fefb65659fff31494146636fa88a0480 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
############################################################################
#
#	File:     wipe.icn
#
#	Subject:  Procedure to wipe window area
#
#	Author:   Ralph E. Griswold
#
#	Date:     May 2, 2001
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  wipe(window, color, direction, x, y, w, h)  "wipes" a rectangular area of
#  window to the specified color.  The direction of wiping can be any one of:
#
#	"right"		from left to right
#	"left"		from right to left
#	"down"		from top to bottom
#	"up		from bottom to top
#	"left-right"	from left and right toward center
#	"up-down"	from top and bottom toward center
#	"in"		from outside to inside
#
#  The default direction is "right".
#
#  The default color is the background color of the window.
#
#  x, y is the top left corner of the area and w and h are the width and
#  height. An omitted value defaults to the one for the entire window.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################

procedure wipe(window, color, direction, x1, y1, w, h)
   local x, y, x2, y2, fg

   /color := Bg(window)			# establish defaults
   /direction := "right"
   /x1 := 0
   /y1 := 0
   /w := WAttrib(window, "width")
   /h := WAttrib(window, "height")
   x2 := x1 + w
   y2 := y1 + h

   fg := Fg(window)				# save present foreground color
   Fg(window, color)				# set foreground for wiping

   if not(integer(x1) & integer(x2) & integer(y1) & integer(y2)) |
      (x1 > x2) | (y1 > y2) then stop("*** illegal coordinates in wipe()")

   case direction of {
      "right": {
         every x := x1 to x2 do {
            DrawLine(window, x, y1, x, y2)
            }
         }
      "left": {
         every x := x2 to x1 by -1 do {
            DrawLine(window, x, y1, x, y2)
            }
         }
      "left-right": {
         until (x2 < x1) do {
           DrawLine(window, x1, y1, x1, y2)
           DrawLine(window, x2, y1, x2, y2)
           x1 +:= 1
           x2 -:= 1
           }
         }
      "up-down": {
          until y2 < y1 do {
            DrawLine(window, x1, y1, x2, y1)
            DrawLine(window, x1, y2, x2, y2)
            y1 +:= 1
            y2 -:= 1
            }
         }
      "down": {
         every y := y1 to y2 do {
            DrawLine(window, x1, y, x2, y)
            }
         }
      "up": {
         every y := y2 to y1 by -1 do {
            DrawLine(window, x1, y, x2, y)
            }
         }
      "in": {
         until (x2 < x1) | (y2 < y1) do {
            DrawLine(window, x1, y1, x1, y2, x2, y2, x2, y1, x1, y1)
            x1 +:= 1
            x2 -:= 1
            y1 +:= 1
            y2 -:= 1
            }
         }
      default: stop("*** illegal direction specificaion in wipe()")
      }

   Fg(window, fg)			# restore foreground color

   return

end