plplot 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,361 @@
1
+ #!/usr/bin/env ruby
2
+ $-w = true if $0 == __FILE__
3
+
4
+ require 'rubygems'
5
+ require 'plplot'
6
+ include PLplot
7
+
8
+ # Displays Greek letters and mathematically interesting Unicode ranges
9
+ # Copyright (C) 2005,2008 Alan Irwin
10
+ # Copyright (C) 2005,2008 Andrew Ross
11
+ #
12
+ #
13
+ # This file is part of PLplot.
14
+ #
15
+ # PLplot is free software; you can redistribute it and/or modify
16
+ # it under the terms of the GNU General Library Public License as published
17
+ # by the Free Software Foundation; either version 2 of the License, or
18
+ # (at your option) any later version.
19
+ #
20
+ # PLplot is distributed in the hope that it will be useful,
21
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ # GNU Library General Public License for more details.
24
+ #
25
+ # You should have received a copy of the GNU Library General Public License
26
+ # along with PLplot; if not, write to the Free Software
27
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28
+
29
+ GREEK = [
30
+ "#gA", "#gB", "#gG", "#gD", "#gE", "#gZ", "#gY", "#gH", "#gI", "#gK", "#gL", "#gM",
31
+ "#gN", "#gC", "#gO", "#gP", "#gR", "#gS", "#gT", "#gU", "#gF", "#gX", "#gQ", "#gW",
32
+ "#ga", "#gb", "#gg", "#gd", "#ge", "#gz", "#gy", "#gh", "#gi", "#gk", "#gl", "#gm",
33
+ "#gn", "#gc", "#go", "#gp", "#gr", "#gs", "#gt", "#gu", "#gf", "#gx", "#gq", "#gw"
34
+ ]
35
+
36
+ TYPE1 = [
37
+ 0x0020, 0x0021, 0x0023, 0x0025, 0x0026,
38
+ 0x0028, 0x0029, 0x002b, 0x002c, 0x002e,
39
+ 0x002f, 0x0030, 0x0031, 0x0032, 0x0033,
40
+ 0x0034, 0x0035, 0x0036, 0x0037, 0x0038,
41
+ 0x0039, 0x003a, 0x003b, 0x003c, 0x003d,
42
+ 0x003e, 0x003f, 0x005b, 0x005d, 0x005f,
43
+ 0x007b, 0x007c, 0x007d, 0x00a9, 0x00ac,
44
+ 0x00ae, 0x00b0, 0x00b1, 0x00d7, 0x00f7,
45
+ 0x0192, 0x0391, 0x0392, 0x0393, 0x0394,
46
+ 0x0395, 0x0396, 0x0397, 0x0398, 0x0399,
47
+ 0x039a, 0x039b, 0x039c, 0x039d, 0x039e,
48
+ 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4,
49
+ 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9,
50
+ 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5,
51
+ 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba,
52
+ 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
53
+ 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4,
54
+ 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9,
55
+ 0x03d1, 0x03d2, 0x03d5, 0x03d6, 0x2022,
56
+ 0x2026, 0x2032, 0x2033, 0x203e, 0x2044,
57
+ 0x2111, 0x2118, 0x211c, 0x2122, 0x2126,
58
+ 0x2135, 0x2190, 0x2191, 0x2192, 0x2193,
59
+ 0x2194, 0x21b5, 0x21d0, 0x21d1, 0x21d2,
60
+ 0x21d3, 0x21d4, 0x2200, 0x2202, 0x2203,
61
+ 0x2205, 0x2206, 0x2207, 0x2208, 0x2209,
62
+ 0x220b, 0x220f, 0x2211, 0x2212, 0x2215,
63
+ 0x2217, 0x221a, 0x221d, 0x221e, 0x2220,
64
+ 0x2227, 0x2228, 0x2229, 0x222a, 0x222b,
65
+ 0x2234, 0x223c, 0x2245, 0x2248, 0x2260,
66
+ 0x2261, 0x2264, 0x2265, 0x2282, 0x2283,
67
+ 0x2284, 0x2286, 0x2287, 0x2295, 0x2297,
68
+ 0x22a5, 0x22c5, 0x2320, 0x2321, 0x2329,
69
+ 0x232a, 0x25ca, 0x2660, 0x2663, 0x2665,
70
+ 0x2666
71
+ ]
72
+
73
+ TITLE = [
74
+ "#<0x10>PLplot Example 23 - Greek Letters",
75
+ "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (a)",
76
+ "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (b)",
77
+ "#<0x10>PLplot Example 23 - Type 1 Symbol Font Glyphs by Unicode (c)",
78
+ "#<0x10>PLplot Example 23 - Number Forms Unicode Block",
79
+ "#<0x10>PLplot Example 23 - Arrows Unicode Block (a)",
80
+ "#<0x10>PLplot Example 23 - Arrows Unicode Block (b)",
81
+ "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (a)",
82
+ "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (b)",
83
+ "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (c)",
84
+ "#<0x10>PLplot Example 23 - Mathematical Operators Unicode Block (d)"
85
+ ]
86
+
87
+ LO = [
88
+ 0x0,
89
+ 0x0,
90
+ 0x40,
91
+ 0x80,
92
+ 0x2153,
93
+ 0x2190,
94
+ 0x21d0,
95
+ 0x2200,
96
+ 0x2240,
97
+ 0x2280,
98
+ 0x22c0
99
+ ]
100
+
101
+ HI = [
102
+ 0x30,
103
+ 0x40,
104
+ 0x80,
105
+ 0xA6,
106
+ 0x2184,
107
+ 0x21d0,
108
+ 0x2200,
109
+ 0x2240,
110
+ 0x2280,
111
+ 0x22c0,
112
+ 0x2300
113
+ ]
114
+
115
+ NXCELLS = [
116
+ 12,
117
+ 8,
118
+ 8,
119
+ 8,
120
+ 8,
121
+ 8,
122
+ 8,
123
+ 8,
124
+ 8,
125
+ 8,
126
+ 8
127
+ ]
128
+
129
+ NYCELLS = [
130
+ 8,
131
+ 8,
132
+ 8,
133
+ 8,
134
+ 8,
135
+ 8,
136
+ 8,
137
+ 8,
138
+ 8,
139
+ 8,
140
+ 8
141
+ ]
142
+
143
+ # non-zero values Must be consistent with NXCELLS and NYCELLS.
144
+ OFFSET = [
145
+ 0,
146
+ 0,
147
+ 64,
148
+ 128,
149
+ 0,
150
+ 0,
151
+ 0,
152
+ 0,
153
+ 0,
154
+ 0,
155
+ 0
156
+ ]
157
+
158
+ # 30 possible FCI values.
159
+
160
+ #define FCI_COMBINATIONS 30
161
+ FCI = [
162
+ 0x80000000,
163
+ 0x80000001,
164
+ 0x80000002,
165
+ 0x80000003,
166
+ 0x80000004,
167
+ 0x80000010,
168
+ 0x80000011,
169
+ 0x80000012,
170
+ 0x80000013,
171
+ 0x80000014,
172
+ 0x80000020,
173
+ 0x80000021,
174
+ 0x80000022,
175
+ 0x80000023,
176
+ 0x80000024,
177
+ 0x80000100,
178
+ 0x80000101,
179
+ 0x80000102,
180
+ 0x80000103,
181
+ 0x80000104,
182
+ 0x80000110,
183
+ 0x80000111,
184
+ 0x80000112,
185
+ 0x80000113,
186
+ 0x80000114,
187
+ 0x80000120,
188
+ 0x80000121,
189
+ 0x80000122,
190
+ 0x80000123,
191
+ 0x80000124,
192
+ ]
193
+
194
+ FAMILY = [
195
+ "sans-serif",
196
+ "serif",
197
+ "monospace",
198
+ "script",
199
+ "symbol",
200
+ ]
201
+
202
+ STYLE = [
203
+ "upright",
204
+ "italic",
205
+ "oblique",
206
+ ]
207
+
208
+ WEIGHT = [
209
+ "medium",
210
+ "bold",
211
+ ]
212
+
213
+ PLOptionParser.parse!
214
+
215
+ plinit
216
+
217
+ (0...11).each do |page|
218
+ pladv( 0 )
219
+
220
+ # Set up viewport and window
221
+
222
+ plvpor( 0.02, 0.98, 0.02, 0.90 )
223
+ plwind( 0.0, 1.0, 0.0, 1.0 )
224
+ xmin, xmax, ymin, ymax = plgspa
225
+ plschr( 0, 0.8 )
226
+ ycharacter_scale = ( 1.0 - 0.0 ) / ( ymax - ymin )
227
+
228
+ # Factor should be 0.5, but heuristically it turns out to be larger.
229
+ chardef, charht = plgchr
230
+ yoffset = 1.0 * charht * ycharacter_scale
231
+
232
+ # Draw the grid using plbox
233
+
234
+ plcol0( 2 )
235
+ deltax = 1.0 / NXCELLS[page]
236
+ deltay = 1.0 / NYCELLS[page]
237
+ plbox( "bcg", deltax, 0, "bcg", deltay, 0 )
238
+ plcol0( 15 )
239
+ length = HI[page] - LO[page]
240
+ slice = 0
241
+ (NYCELLS[page] - 1).downto(-1) do |j|
242
+ y = ( 0.5 + j ) * deltay
243
+ NXCELLS[page].times do |i|
244
+ x = ( 0.5 + i ) * deltax
245
+ if ( slice < length )
246
+ if ( page == 0 )
247
+ cmdString = sprintf( "#%s", GREEK[slice] )
248
+ elsif ( ( page >= 1 ) && ( page <= 3 ) )
249
+ cmdString = sprintf( "##[0x%.4x]", TYPE1[OFFSET[page] + slice] )
250
+ elsif ( page >= 4 )
251
+ cmdString = sprintf( "##[0x%.4x]", LO[page] + slice )
252
+ end
253
+ plptex( x, y + yoffset, 1, 0, 0.5, cmdString[1..-1] )
254
+ plptex( x, y - yoffset, 1, 0, 0.5, cmdString )
255
+ end
256
+ slice += 1
257
+ end
258
+ end
259
+
260
+ plschr( 0, 1 )
261
+ # Page title
262
+ plmtex( "t", 1.5, 0.5, 0.5, TITLE[page] )
263
+ end
264
+
265
+ # Demonstrate methods of getting the current fonts
266
+ fci_old = plgfci
267
+ ifamily, istyle, iweight = plgfont
268
+ printf( "For example 23 prior to page 12 the FCI is 0x%x\n", fci_old )
269
+ printf( "For example 23 prior to page 12 the font family, style and weight are %s %s %s\n", FAMILY[ifamily], STYLE[istyle], WEIGHT[iweight] )
270
+
271
+ (11...16).each do |page|
272
+ dy = 0.030
273
+
274
+ pladv( 0 )
275
+ plvpor( 0.02, 0.98, 0.02, 0.90 )
276
+ plwind( 0.0, 1.0, 0.0, 1.0 )
277
+ plsfci( 0 )
278
+ if ( page == 11 )
279
+ plmtex( "t", 1.5, 0.5, 0.5,
280
+ "#<0x10>PLplot Example 23 - " \
281
+ "Set Font with plsfci" )
282
+ elsif ( page == 12 )
283
+ plmtex( "t", 1.5, 0.5, 0.5,
284
+ "#<0x10>PLplot Example 23 - " \
285
+ "Set Font with plsfont" )
286
+ elsif ( page == 13 )
287
+ plmtex( "t", 1.5, 0.5, 0.5,
288
+ "#<0x10>PLplot Example 23 - " \
289
+ "Set Font with ##<0x8nnnnnnn> construct" )
290
+ elsif ( page == 14 )
291
+ plmtex( "t", 1.5, 0.5, 0.5,
292
+ "#<0x10>PLplot Example 23 - " \
293
+ "Set Font with ##<0xmn> constructs" )
294
+ elsif ( page == 15 )
295
+ plmtex( "t", 1.5, 0.5, 0.5,
296
+ "#<0x10>PLplot Example 23 - " \
297
+ "Set Font with ##<FCI COMMAND STRING/> constructs" )
298
+ end
299
+ plschr( 0, 0.75 )
300
+ FCI.each_index do |i|
301
+ family_index = i % 5
302
+ style_index = ( i / 5 ) % 3
303
+ weight_index = ( ( i / 5 ) / 3 ) % 2
304
+ if ( page == 11 )
305
+ plsfci( FCI[i] )
306
+ string = sprintf(
307
+ "Page 12, %s, %s, %s: " \
308
+ "The quick brown fox jumps over the lazy dog",
309
+ FAMILY[family_index],
310
+ STYLE[style_index],
311
+ WEIGHT[weight_index] )
312
+ elsif ( page == 12 )
313
+ plsfont( family_index, style_index, weight_index )
314
+ string = sprintf(
315
+ "Page 13, %s, %s, %s: " \
316
+ "The quick brown fox jumps over the lazy dog",
317
+ FAMILY[family_index],
318
+ STYLE[style_index],
319
+ WEIGHT[weight_index] )
320
+ elsif ( page == 13 )
321
+ string = sprintf(
322
+ "Page 14, %s, %s, %s: " \
323
+ "#<0x%x>" \
324
+ "The quick brown fox jumps over the lazy dog",
325
+ FAMILY[family_index],
326
+ STYLE[style_index],
327
+ WEIGHT[weight_index],
328
+ FCI[i] )
329
+ elsif ( page == 14 )
330
+ string = sprintf(
331
+ "Page 15, %s, %s, %s: " \
332
+ "#<0x%1x0>#<0x%1x1>#<0x%1x2>" \
333
+ "The quick brown fox jumps over the lazy dog",
334
+ FAMILY[family_index],
335
+ STYLE[style_index],
336
+ WEIGHT[weight_index],
337
+ family_index,
338
+ style_index,
339
+ weight_index )
340
+ elsif ( page == 15 )
341
+ string = sprintf(
342
+ "Page 16, %s, %s, %s: " \
343
+ "#<%s/>#<%s/>#<%s/>" \
344
+ "The quick brown fox jumps over the lazy dog",
345
+ FAMILY[family_index],
346
+ STYLE[style_index],
347
+ WEIGHT[weight_index],
348
+ FAMILY[family_index],
349
+ STYLE[style_index],
350
+ WEIGHT[weight_index] )
351
+ end
352
+ plptex( 0, 1 - ( i + 0.5 ) * dy, 1, 0, 0, string )
353
+ end
354
+
355
+ plschr( 0, 1.0 )
356
+ end
357
+
358
+ # Restore defaults
359
+ plcol0( 1 )
360
+
361
+ plend
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ $-w = true if $0 == __FILE__
4
+
5
+ require 'rubygems'
6
+ require 'plplot'
7
+ include PLplot
8
+
9
+ # Unicode Pace Flag
10
+ #
11
+ # Copyright (C) 2005 Rafael Laboissiere
12
+ #
13
+ #
14
+ # This file is part of PLplot.
15
+ #
16
+ # PLplot is free software; you can redistribute it and/or modify
17
+ # it under the terms of the GNU General Library Public License as published
18
+ # by the Free Software Foundation; either version 2 of the License, or
19
+ # (at your option) any later version.
20
+ #
21
+ # PLplot is distributed in the hope that it will be useful,
22
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ # GNU Library General Public License for more details.
25
+ #
26
+ # You should have received a copy of the GNU Library General Public License
27
+ # along with PLplot; if not, write to the Free Software
28
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29
+
30
+ red = [ 240, 204, 204, 204, 0, 39, 125 ]
31
+ green = [ 240, 0, 125, 204, 204, 80, 0 ]
32
+ blue = [ 240, 0, 0, 0, 0, 204, 125 ]
33
+
34
+ px = [ 0.0, 0.0, 1.0, 1.0 ]
35
+ py = [ 0.0, 0.25, 0.25, 0.0 ]
36
+
37
+ sx = [
38
+ 0.16374,
39
+ 0.15844,
40
+ 0.15255,
41
+ 0.17332,
42
+ 0.50436,
43
+ 0.51721,
44
+ 0.49520,
45
+ 0.48713,
46
+ 0.83976,
47
+ 0.81688,
48
+ 0.82231,
49
+ 0.82647
50
+ ]
51
+
52
+ sy = [
53
+ 0.125,
54
+ 0.375,
55
+ 0.625,
56
+ 0.875,
57
+ 0.125,
58
+ 0.375,
59
+ 0.625,
60
+ 0.875,
61
+ 0.125,
62
+ 0.375,
63
+ 0.625,
64
+ 0.875
65
+ ]
66
+
67
+ # Taken from http://www.columbia.edu/~fdc/pace/
68
+
69
+ peace = [
70
+ # Mandarin */
71
+ "#<0x00>和平",
72
+ # Hindi */
73
+ "#<0x20>शांति",
74
+ # English */
75
+ "#<0x10>Peace",
76
+ # Hebrew */
77
+ "#<0x10>שלום",
78
+ # Russian */
79
+ "#<0x10>Мир",
80
+ # German */
81
+ "#<0x10>Friede",
82
+ # Korean */
83
+ "#<0x30>평화",
84
+ # French */
85
+ "#<0x10>Paix",
86
+ # Spanish */
87
+ "#<0x10>Paz",
88
+ # Arabic */
89
+ "#<0x10>ﺳﻼم",
90
+ # Turkish*/
91
+ "#<0x10>Barış",
92
+ # Kurdish */
93
+ "#<0x10>Hasîtî",
94
+ ]
95
+
96
+ PLOptionParser.parse!
97
+
98
+ plinit
99
+
100
+ pladv(0)
101
+ plvpor(0.0, 1.0, 0.0, 1.0)
102
+ plwind(0.0, 1.0, 0.0, 1.0)
103
+ plcol0(0)
104
+ plbox("", 1.0, 0, "", 1.0, 0)
105
+
106
+ plscmap0n(7)
107
+ plscmap0(red, green, blue)
108
+
109
+ plschr(0, 4.0)
110
+ plfont(1)
111
+
112
+ 4.times do |i|
113
+ plcol0(i + 1)
114
+ plfill(px, py)
115
+
116
+ 4.times do |j|
117
+ py[j] += 1.0 / 4.0
118
+ end
119
+ end
120
+
121
+ plcol0(0)
122
+ peace.each_index do |i|
123
+ plptex(sx[i], sy[i], 1.0, 0.0, 0.5, peace[i])
124
+ end
125
+
126
+ plend