Skip to content

Commit d4d0a63

Browse files
committed
new
0 parents  commit d4d0a63

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+7589
-0
lines changed

allclose.gs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
*
2+
* Help is in the end of this script.
3+
*
4+
function allclose( args )
5+
_version='0.01r1'
6+
7+
* if( args = '' )
8+
* help()
9+
* return
10+
* endif
11+
12+
* serach for the largest file number
13+
'q files'
14+
i = 1
15+
fmax = 0
16+
while( 1 )
17+
line = sublin( result, i )
18+
if( line = '' ) ; break ; endif
19+
num = subwrd( line, 2 )
20+
if( num = fmax + 1 ) ; fmax = fmax + 1 ; endif
21+
i = i + 1
22+
endwhile
23+
24+
* close
25+
say 'closing 'fmax' files'
26+
f = fmax
27+
while( f >= 1 )
28+
'close 'f
29+
f = f - 1
30+
endwhile
31+
32+
return
33+
34+
*
35+
* help
36+
*
37+
function help()
38+
say ' Name:'
39+
say ' allclose '_version' - close all the opened files'
40+
say ' '
41+
say ' Usage:'
42+
say ' allclose'
43+
say ''
44+
say ' Copyright (C) 2010 Chihiro Kodama'
45+
say ' Distributed under GNU GPL (http://www.gnu.org/licenses/gpl.html)'
46+
say ''
47+
return

allcolor.gs

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
*
2+
* Help is in the end of this script.
3+
*
4+
function allcolor(args)
5+
_version='0.01r1'
6+
7+
if( args = '' )
8+
help()
9+
endif
10+
11+
imax = 20
12+
jmax = 10
13+
14+
c = 0
15+
while( c <= 255 )
16+
'set line 'c
17+
i = math_fmod( c, imax )
18+
j = ( c - i ) / imax
19+
20+
x1 = 0.5 + 0.5 * i
21+
x2 = 0.5 + 0.5 * (i+1)
22+
xmed = ( x1 + x2 ) / 2.0
23+
24+
y1 = 7.5 - 0.5 * j
25+
y2 = 7.5 - 0.5 * (j-1)
26+
ymed = ( y1 + y2 ) / 2.0
27+
28+
'draw recf 'x1' 'y1' 'x2' 'y2
29+
30+
'set strsiz 0.1 0.15'
31+
'set string 0 c 0.15'
32+
'draw string 'xmed' 'ymed' 'c
33+
34+
c = c + 1
35+
endwhile
36+
37+
return
38+
39+
40+
*
41+
* help
42+
*
43+
function help()
44+
say ' Name:'
45+
say ' allcolor '_version' - display all the colors'
46+
say ' '
47+
say ' Usage:'
48+
say ' allcolor'
49+
say ''
50+
say ' Copyright (C) 2009-2011 Chihiro Kodama'
51+
say ' Distributed under GNU GPL (http://www.gnu.org/licenses/gpl.html)'
52+
say ''
53+
return

arg.gsf

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
* get argument of z=x+iy in radian.
2+
function arg( x, y )
3+
pi = 4 * math_atan(1.0)
4+
if( x > 0 & y > 0 ) ; ret = math_atan( y / x ) ; endif
5+
if( x < 0 & y > 0 ) ; ret = _pi - math_atan( y / (-x) ) ; endif
6+
if( x < 0 & y < 0 ) ; ret = _pi + math_atan( y / x ) ; endif
7+
if( x > 0 & y < 0 ) ; ret = 2*_pi - math_atan( (-y) / x ) ; endif
8+
9+
if( x = 0 & y > 0 ) ; ret = 0.5*_pi; endif
10+
if( x = 0 & y < 0 ) ; ret = 1.5*_pi; endif
11+
if( x > 0 & y = 0 ) ; ret = 0.0*_pi; endif
12+
if( x < 0 & y = 0 ) ; ret = 1.0*_pi; endif
13+
if( x = 0 & y = 0 ) ; ret = 9999; endif
14+
*say 'arg: ' % x % ' - ' % y % ' - ' % ret
15+
16+
return ret

arrow.gs

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
*
2+
* Help is in the end of this script
3+
*
4+
function clave( args )
5+
_version='0.01r2'
6+
7+
if( args = '' )
8+
help()
9+
return
10+
endif
11+
12+
***** Default value *****
13+
x1 = -1
14+
y1 = -1
15+
x2 = -1
16+
y2 = -1
17+
angle = 30
18+
head = '20%'
19+
20+
***** Arguement *****
21+
i = 1
22+
while( 1 )
23+
arg = subwrd( args, i )
24+
i = i + 1;
25+
if( arg = '' ); break; endif
26+
27+
while(1)
28+
*** option
29+
if( arg = '-angle'); angle=subwrd(args,i); i=i+1; break; endif
30+
if( arg = '-head'); head=subwrd(args,i); i=i+1; break; endif
31+
32+
*** x1, y1, x2, y2
33+
if( x1 = -1 ); x1 = arg; break; endif
34+
if( y1 = -1 ); y1 = arg; break; endif
35+
if( x2 = -1 ); x2 = arg; break; endif
36+
if( y2 = -1 ); y2 = arg; break; endif
37+
38+
say 'syntax error : 'arg
39+
return
40+
41+
endwhile
42+
endwhile
43+
44+
if( substr( head, math_strlen(head), 1 ) = '%' )
45+
head = substr( head, 1, math_strlen(head)-1 )
46+
head = math_sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) ) * head / 100.0
47+
endif
48+
49+
***** Draw *****
50+
pi = 3.14159
51+
alpha = math_atan2( y2-y1, x2-x1 )
52+
53+
'draw line 'x1' 'y1' 'x2' 'y2
54+
55+
x = x2 + head * math_cos( (180+angle)*pi/180 + alpha )
56+
y = y2 + head * math_sin( (180+angle)*pi/180 + alpha )
57+
'draw line 'x2' 'y2' 'x' 'y
58+
59+
x = x2 + head * math_cos( (180-angle)*pi/180 + alpha )
60+
y = y2 + head * math_sin( (180-angle)*pi/180 + alpha )
61+
'draw line 'x2' 'y2' 'x' 'y
62+
63+
return
64+
65+
66+
*
67+
* help
68+
*
69+
function help()
70+
say ' Name:'
71+
say ' arrow '_version' - draw arrow '
72+
say ' '
73+
say ' Usage:'
74+
say ' arrow x1 y1 x2 y2 [-angle angle] [-head head[%]]'
75+
say ''
76+
say ' x1 y1 : start point'
77+
say ' x2 y2 ; end point'
78+
say ' angle : arrow head angle. default=30.'
79+
say ' head[%] : arrow head length. default=20%'
80+
say ' If you specify %, '
81+
say ' then the length will be set relative to the arrow length.'
82+
say ''
83+
say ' Note:'
84+
say ' [arg-name] : specify if needed'
85+
say ' (arg1 | arg2) : arg1 or arg2 must be specified'
86+
say ''
87+
say ' Copyright (C) 2009 Chihiro Kodama'
88+
say ' Distributed under GNU GPL (http://www.gnu.org/licenses/gpl.html)'
89+
say ''
90+
return

atoi.gsf

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
***** char -> integer *****
2+
function atoi( char )
3+
rc = gsfallow( 'on' )
4+
5+
* avoid bug in GrADS 1.9 or less ('e' and '+' are assumed to be same)
6+
a='1'char'5'
7+
if( a = 1e+5 ) ; return 101 ; endif
8+
if( a = '1+5' ) ; return 43 ; endif
9+
10+
if( char = a ) ; return 43 ; endif
11+
if( char = 'e' ) ; return 101 ; endif
12+
i = 32
13+
while( i <= 126 )
14+
if( itoa(i) = char ) ; return i ; endif
15+
i = i + 1
16+
endwhile
17+
return -1

chcase.gsf

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
* type = 'upper' or 'lower' or 'upper-first'
2+
function chcase( str, type )
3+
ret = ''
4+
i = 1
5+
length = math_strlen( str )
6+
while( i <= length )
7+
c = substr( str, i, 1 )
8+
c = atoi( c )
9+
if( type = 'upper' & c >= 97 & c <= 122 )
10+
c = c - 32
11+
endif
12+
if( type = 'upper_first' & c >= 97 & c <= 122 & i = 1 )
13+
c = c - 32
14+
endif
15+
if( type = 'lower' & c >= 65 & c <= 90 )
16+
c = c + 32
17+
endif
18+
if( type = 'upper_first' & c >= 65 & c <= 90 & i != 1 )
19+
c = c + 32
20+
endif
21+
c = itoa( c )
22+
ret = ret % c
23+
i = i + 1
24+
endwhile
25+
return ret

0 commit comments

Comments
 (0)