blob: be42c774c78782c14f77196d25c838a82666c628 (
plain) (
blame)
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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <gki.h>
# IDSLUTFILL -- Fill a lookup table from a set of line end points
procedure idslfill (in, icount, out, lenlut, lutmin, lutmax)
short in[ARB] # input: line end points
int icount # number of input data items
short out[ARB] # output: the lookup table
int lenlut # lut size
int lutmin,lutmax # inclusive range for lut values
int i,j
int xs, ys, xe, ye
real slope
begin
# xs and xe are zero based coordinates
xs = real(in[1]) * (lenlut - 1)/GKI_MAXNDC. + 0.5
ys = real(in[2]) * (lutmax - lutmin)/GKI_MAXNDC. + lutmin + 0.5
do i = 3, icount, 2 {
xe = real(in[i]) * (lenlut - 1)/GKI_MAXNDC. + 0.5
ye = real(in[i+1]) * (lutmax - lutmin)/GKI_MAXNDC. + lutmin + 0.5
if (xe != xs) {
slope = real(ye - ys) / (xe - xs)
do j = xs, xe {
out[j+1] = ys + (j - xs) * slope
}
}
xs = xe
ys = ye
}
out[1] = 0 # keep background at zero
end
|