-
Notifications
You must be signed in to change notification settings - Fork 74
/
Tips.p
179 lines (127 loc) · 3.35 KB
/
Tips.p
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
{Photoshop version 1.0.1, file: Tips.p
Computer History Museum, www.computerhistory.org
This material is (C)Copyright 1990 Adobe Systems Inc.
It may not be distributed to third parties.
It is licensed for non-commercial use according to
www.computerhistory.org/softwarelicense/photoshop/ }
PROGRAM Tips;
VAR
rows: INTEGER;
cols: INTEGER;
data: ARRAY [0..18, 0..18] OF INTEGER;
{*****************************************************************************}
PROCEDURE WriteTip (id: INTEGER);
VAR
r, c: INTEGER;
BEGIN
WRITELN;
WRITELN ('resource ''TIP '' (', id:1, ', purgeable)');
WRITELN (' {');
WRITELN (' {', rows :2, ', ', cols :2, '},');
WRITELN (' {', rows DIV 2:2, ', ', cols DIV 2:2, '},');
WRITELN (' {');
FOR r := 0 TO rows - 1 DO
BEGIN
WRITE (' ');
FOR c := 0 TO cols - 1 DO
BEGIN
WRITE (data [r, c]:3);
IF (r <> rows - 1) OR (c <> cols - 1) THEN
WRITE (';');
END;
WRITELN
END;
WRITELN (' }');
WRITELN (' };')
END;
{*****************************************************************************}
FUNCTION GaussianWeight (r, c: INTEGER): INTEGER;
VAR
sigma: EXTENDED;
radius: EXTENDED;
BEGIN
IF rows > cols THEN
sigma := rows * 0.5
ELSE
sigma := cols * 0.5;
radius := SQRT (SQR (r - rows DIV 2) + SQR (c - cols DIV 2));
IF radius > sigma THEN
GaussianWeight := 0
ELSE
GaussianWeight := ROUND (255.0 * EXP (-SQR (radius / sigma * 2.0)))
END;
{*****************************************************************************}
PROCEDURE GaussianTip (id, rr, cc: INTEGER);
VAR
r, c: INTEGER;
BEGIN
rows := rr;
cols := cc;
FOR r := 0 TO rows - 1 DO
FOR c := 0 TO cols - 1 DO
data [r, c] := GaussianWeight (r, c);
WriteTip (id)
END;
{*****************************************************************************}
FUNCTION SquareWeight (r, c: INTEGER): INTEGER;
VAR
dr: INTEGER;
dc: INTEGER;
radius: LONGINT;
BEGIN
dr := ABS (r - rows DIV 2);
dc := ABS (c - cols DIV 2);
IF dr < dc THEN
radius := dc
ELSE
radius := dr;
SquareWeight := ROUND (255 * (1.0 - radius / ((cols + 1) DIV 2)))
END;
{*****************************************************************************}
PROCEDURE SquareTip (id, rr, cc: INTEGER);
VAR
r, c: INTEGER;
BEGIN
rows := rr;
cols := cc;
FOR r := 0 TO rows - 1 DO
FOR c := 0 TO cols - 1 DO
data [r, c] := SquareWeight (r, c);
WriteTip (id)
END;
{*****************************************************************************}
BEGIN
WRITELN ('type ''TIP ''' );
WRITELN (' {' );
WRITELN (' point;' );
WRITELN (' point;' );
WRITELN (' wide array' );
WRITELN (' {' );
WRITELN (' unsigned byte;' );
WRITELN (' };' );
WRITELN (' };' );
GaussianTip ( 1, 1, 1);
GaussianTip ( 2, 3, 3);
GaussianTip ( 3, 5, 5);
GaussianTip ( 4, 7, 7);
GaussianTip ( 5, 9, 9);
GaussianTip ( 6, 11, 11);
GaussianTip ( 7, 13, 13);
GaussianTip ( 8, 15, 15);
GaussianTip ( 9, 17, 17);
GaussianTip (10, 19, 19);
SquareTip (11, 7, 7);
SquareTip (12, 9, 9);
SquareTip (13, 11, 11);
SquareTip (14, 13, 13);
GaussianTip (15, 3, 1);
GaussianTip (16, 5, 1);
GaussianTip (17, 7, 1);
GaussianTip (18, 9, 1);
GaussianTip (19, 11, 1);
GaussianTip (20, 1, 3);
GaussianTip (21, 1, 5);
GaussianTip (22, 1, 7);
GaussianTip (23, 1, 9);
GaussianTip (24, 1, 11)
END.