Roll src/third_party/WebKit 06cb9e9:a978ee5 (svn 202558:202559)
[chromium-blink-merge.git] / third_party / lcov / contrib / galaxy / posterize.pl
blob1b2895ede67e94eb0b96e712fb05569faa631325
1 #!/usr/bin/perl
3 # Copyright (c) International Business Machines Corp., 2002
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or (at
8 # your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # posterize.pl
22 # This script generates a postscript file from output generated from the
23 # fcgp http://sourceforge.net/projects/fcgp/ for plotting
26 # History:
27 # 2003-09-04 wrote - James M Kenefick Jr. <jkenefic@us.ibm.com>
32 # a good deal of this could be turned in to cli
33 # arguments.
35 # Constants
36 my $Title = "Linux Kernel Coverage";
37 my $KernelVersion = "2.5.73";
38 my $TestDescription = "A Sample Print";
39 my $Image = "../lgp/image.ps";
41 # Variables
42 my $Bounds = "";
43 # Paper sizes in inches
44 my $PAPER_WIDTH = 34;
45 my $PAPER_HEIGHT = 42;
47 # points per inch
48 my $ppi = 72;
50 # Margins
51 my $TopMargin = 1;
52 my $BottomMargin = 1.5;
53 my $LeftMargin = 1;
54 my $RightMargin = 1;
57 $RightMargin = $PAPER_WIDTH - $RightMargin;
58 $TopMargin = $PAPER_HEIGHT - $TopMargin;
60 my $filename = "poster.ps";
62 # Sizes in ppi
63 my $PPI_WIDTH = ($PAPER_WIDTH * $ppi);
64 my $PPI_HEIGHT = ($PAPER_HEIGHT * $ppi);
66 # Date we create poster
67 my $date = `date`;
69 print STDERR "Creating Poster\n";
71 open POSTER, ">$filename";
75 print(POSTER <<END_OF_USAGE);
76 %!PS-Adobe-1.0
77 %%DocumentFonts: Helvetica Helvetica-Bold
78 %%Title: Linux 2.4.0 Kernel Poster
79 %%Creator: Rusty's scripts and postersize (GPL)
80 %%CreationDate: $date
81 %%Pages: 1
82 %%BoundingBox: 0 0 $PPI_WIDTH $PPI_HEIGHT
83 %%EndComments
85 /PRorig_showpage_x178313 /showpage load def /showpage{
86 errordict /handleerror {} put
87 }def
88 /initgraphics{}def/setpagedevice{pop}def
89 statusdict begin /a4tray{}def /lettertray{}def end
90 /a4{}def/a3{}def/a0{}def/letter{}def/legal{}def
91 /a4small{}def /lettersmall{}def /a4tray{}def /lettertray{}def
92 /setscreen{pop pop pop}def
93 /ColorManagement {pop} def
96 /A {gsave newpath 0 360 arc stroke grestore} bind def
97 /M {moveto} bind def
98 /L {lineto} bind def
99 /D {[] 0 setdash} bind def
100 /D5 {[5] 0 setdash} bind def
101 /C0 {0 0 0 setrgbcolor} bind def
102 /C1 {.8 .4 .4 setrgbcolor} bind def
103 /C2 {.5 1 .5 setrgbcolor} bind def
104 /C3 {0 .7 0 setrgbcolor} bind def
105 /C4 {1 0 0 setrgbcolor} bind def
106 /C5 {0 0 1 setrgbcolor} bind def
107 /R {grestore} bind def
108 /S {0 0 M stroke} bind def
109 /T {gsave translate} bind def
110 /U {C0 newpath 4 copy 4 2 roll 8 7 roll M L L L closepath stroke
111 C1 findfont exch scalefont setfont M show} bind def
113 % Added James M Kenefick Jr.
114 /Hi_Color {0 0 1} def
115 /Med_Color {0 .60 1} def
116 /Lo_Color {0 1 1} def
117 /None_Color {.75 .75 .75} def
118 /Hi {newpath 4 copy 4 2 roll 8 7 roll M L L L Hi_Color setrgbcolor fill closepath} bind def
119 /Med {newpath 4 copy 4 2 roll 8 7 roll M L L L Med_Color setrgbcolor fill closepath} bind def
120 /Lo {newpath 4 copy 4 2 roll 8 7 roll M L L L Lo_Color setrgbcolor fill closepath} bind def
121 /None {newpath 4 copy 4 2 roll 8 7 roll M L L L None_Color setrgbcolor fill closepath} bind def
123 /inch
125 72 mul
129 /LeftMargin $LeftMargin inch def
130 /RightMargin $RightMargin inch def
131 /TopMargin $TopMargin inch def
132 /BottomMargin $BottomMargin inch def
133 /FontScale 25 def
134 /AuthorFontScale 70 def
136 /centerText
139 stringwidth pop
140 2 div
141 RightMargin LeftMargin sub 2 div
142 exch sub
143 LeftMargin add
144 NextLine moveto
145 show
149 /upLine
151 /NextLine
152 NextLine LineSpace2 add
157 /advanceLine
159 /NextLine
160 NextLine LineSpace sub
165 /fontScale
167 TopMargin BottomMargin sub FontScale div
171 /authorfontScale
173 TopMargin BottomMargin sub AuthorFontScale div
177 /rightJustify
180 stringwidth pop
181 RightMargin 1 inch sub
182 exch sub
183 NextLine moveto
184 show
188 /usableY
190 TopMargin LineSpace 3 mul sub BottomMargin sub
194 /usableX
196 RightMargin LeftMargin sub
199 gsave
200 /Times-Roman findfont fontScale scalefont setfont
201 /LineSpace fontScale def
202 /NextLine (B) stringwidth pop TopMargin exch sub def
204 %%EndProlog
205 %%Page 1
206 % title
208 ($Title) centerText advanceLine
209 (Kernel: $KernelVersion) centerText advanceLine
210 ($TestDescription) centerText
212 % Author Block
213 LeftMargin BottomMargin translate
214 /Times-Roman findfont authorfontScale scalefont setfont
215 /LineSpace2 authorfontScale def
216 /NextLine 0 def
217 (Based on work by Rusty Russell, Christian Reiniger) rightJustify
218 upLine
219 (By James M. Kenefick Jr.) rightJustify
221 grestore
222 LeftMargin BottomMargin translate
224 % Key Block
225 15 15 scale
226 % This is the key for the graph.
228 /box { newpath moveto 0 1 rlineto 2 0 rlineto 0 -1 rlineto closepath } def
229 /key { setrgbcolor 2 copy box gsave fill grestore 0 0 0 setrgbcolor strokepath fill moveto 2.4 0.25 rmoveto show } def
231 /Helvetica-Oblique findfont
232 1 scalefont setfont
233 0.1 setlinewidth
235 (static functions) 1 5 0.5 1 0.5 key % Light green.
236 (indirectly called functions) 1 7 0 0.7 0 key % green
237 (exported functions) 1 9 1 0 0 key % red
238 (other functions) 1 11 0 0 1 key % blue
240 (Low Coverage) 1 15 Lo_Color key % blue
241 (Medium Coverage) 1 17 Med_Color key % blue
242 (Hi Coverage) 1 19 Hi_Color key % blue
243 (No Coverage) 1 21 None_Color key % blue
244 1 3.25 moveto
245 0.8 0.4 0.4 setrgbcolor
246 /Helvetica findfont
247 1 scalefont setfont
248 (xxx) show
249 1 3 moveto
250 2.4 0.25 rmoveto
251 0 0 0 setrgbcolor
252 /Helvetica-Oblique findfont
253 1 scalefont setfont
254 (function name) show
256 1 1.25 moveto
257 0.8 0.4 0.4 setrgbcolor
258 /Helvetica-Bold findfont
259 1 scalefont setfont
260 (xxx) show
261 1 1 moveto
262 2.4 0.25 rmoveto
263 0 0 0 setrgbcolor
264 /Helvetica-Oblique findfont
265 1 scalefont setfont
266 (source filename) show
268 6 24 moveto
269 /Helvetica-Bold findfont
270 2 scalefont setfont
271 (Key) show
273 % Box around it
274 newpath
275 0.2 0.2 moveto
276 0.2 27 lineto
277 17 27 lineto
278 17 0.2 lineto
279 closepath
280 strokepath fill
283 1 15 div 1 15 div scale
285 % find and move to center
286 END_OF_USAGE
288 # Find the bounds for the image
290 $Bounds = `tail -1 $Image`;
291 ($Junk, $Junk, $minX, $minY, $maxX, $maxY) = split / /, $Bounds;
293 my $xRange = $maxX - $minX;
294 my $yRange = $maxY - $minY;
296 if ($xRange < $yRange){
297 $Range = $xRange;
298 } else {
299 $Range = $yRange;
301 print POSTER " 0 usableY usableX sub 2 div translate\n";
302 print POSTER "usableX $Range div usableX $Range div scale\n";
303 print POSTER "$Range 2 div $Range 2 div translate\n";
304 print POSTER "gsave\n";
305 # Paste in actual image.
306 print POSTER `cat /home/lgp/image.ps`;
307 print POSTER "%%Trailer\n";
308 print POSTER "grestore\n";
309 print POSTER "showpage\n";
310 print POSTER "PRorig_showpage_x178313\n";
311 print POSTER "/showpage /PRorig_showpage_x178313 load def\n";