-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathnulldev.ps
More file actions
87 lines (74 loc) · 2.17 KB
/
nulldev.ps
File metadata and controls
87 lines (74 loc) · 2.17 KB
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
/QUIET where { pop }{ (loading nulldev.ps...)print } ifelse
/DEVICE { graphicsdict /currgstate get /device get } def
/nulldevice {
graphicsdict /currgstate get /device
612 792 newnulldevice
put
} def
/newnulldevice { % width height
NULLDEV dup /Create get exec
} def
% NULLDEV device implements the "nulldevice", which
% does no drawing, but otherwise performs all graphics operations
% and will return appropriately-transformed graphics state parameters.
%
% In the list of procedures below, PGMIMAGE is the Class dictionary,
% IMAGE is an instance returned by Create.
% The nulldevice implementations of these methods
% merely have to consume these arguments from the stack
% using `pop`.
%
% procedures:
% width height PGMIMAGE Create -> IMAGE
% val x y IMAGE PutPix -> -
% x y IMAGE GetPix -> val
% val x1 y1 x2 y2 IMAGE DrawLine -> -
% val x y width height IMAGE DrawRect -> -
% val x y width height IMAGE FillRect -> -
% val polygon IMAGE FillPoly -> -
% IMAGE Emit -> -
% IMAGE Destroy -> -
% dict1 .copydict dict2
%
/NULLDEV <<
/nativecolorspace /DeviceGray
/dimensions [0 0]
/.copydict {
dup length dict copy
dup /width known {
dup begin
/dimensions [width height] def
end
} if
}
/Create { % width height IMAGE . IMAGE'
begin {/height /width}{exch def}forall
currentdict end
dup /.copydict get exec
}
/Destroy { % IMAGE . -
pop
}
/PutPix { % val x y IMAGE . -
pop pop pop pop
}
/GetPix { % x y IMAGE . val
pop pop pop 0
}
/DrawLine { % val x1 y1 x2 y2 IMAGE . -
pop pop pop pop pop pop
}
/DrawRect { % val x y w h IMAGE . -
pop pop pop pop pop pop
}
/FillRect { % val x y w h IMAGE . -
pop pop pop pop pop pop
}
/FillPoly { % val polygon IMAGE . -
pop pop pop
}
/Emit {
pop
}
>> def
/QUIET where { pop }{ (eof nulldev.ps\n)print } ifelse