summaryrefslogtreecommitdiff
path: root/ipl/gprocs/tile.icn
blob: f66d314b22b58717721ffb7ef1371f55566434c9 (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
############################################################################
#
#	File:     tile.icn
#
#	Subject:  Procedure to tile window
#
#	Author:   Ralph E. Griswold
#
#	Date:     September 29, 1997
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This procedure tiles a portion of win1 over the specified portion
#  of win2, doubling to reduce the number of copies required.
#
############################################################################
#
#  Requires:  Version 9 graphics
#
############################################################################

procedure tile(win1, win2, x1, y1, w1, h1)	#: tile area with image
   local w, h, wmax, hmax

   /win1 := &window
   /win2 := &window
   /x1 := 0
   /y1 := 0
   /w1 := WAttrib(win1, "width")
   /h1 := WAttrib(win1, "height")
   wmax := WAttrib(win2, "width")
   hmax := WAttrib(win2, "height")

   if (w1 | h1) = 0 then fail

   if w1 < 0 then {
      w1 := -w1
      x1 -:= w1
      }

   if h1 < 0 then {
      h1 := -h1
      y1 -:= h1
      }

   CopyArea(win1, win2, x1, y1, w1, h1)		# initial copy 

   while w1 < wmax do {				# copy and double
      CopyArea(win2, win2, 0, 0, w1, h1, w1, 0)
      w1 *:= 2
      }

   while h1 < hmax do {				# copy and double
      CopyArea(win2, win2, 0, 0, w1, h1, 0, h1)
      h1 *:= 2
      }

   return

end