make_tartan_files.anubis
2.24 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
A demo for the ``Tartan'' generator.
Author: Alain Prouté
Compile this file and execute:
anbexec make_tartan_files 10
to generate 10 tartan images.
--- That's all for the public part ! --------------------------------------------------
read tools/basis.anubis
read tartan_generator.anubis
define One
make_files
(
Int w,
Int h,
Int n
) =
if n =< 0 then unique else
if unow is utime(sec,msec) then
with im = make_tartan_image(w,h),
if write_image_to_JPEG_file(to_JPEG(im),"tartan_"+to_decimal(sec)+"_"+to_decimal(msec)+".jpg",95) is
{
cannot_create_file then print("Cannot create JPEG file.\n\n"),
compression_error then print("JPEG compression error.\n\n"),
ok then print("JPEG file created ("+to_decimal(n)+")\n");
make_files(w,h,n-1)
}.
define One
usage =
print("Usage: anbexec make_tartan_files <width> <height> <how many>\n"+
" where <width> and <height> is the size of the image,\n"+
" and where <how many> is the number of files to generate.\n\n").
global define One
make_tartan_files
(
List(String) args
) =
if args is
{
[ ] then usage,
[h1 . t1] then if decimal_scan(h1) is
{
failure then print("Argument <width> has not been recognized as an integer.\n\n"),
success(w) then if t1 is
{
[ ] then usage,
[h2 . t2] then if decimal_scan(h2) is
{
failure then print("Argument <height> has not been recognized as an integer.\n\n"),
success(h) then if t2 is
{
[ ] then usage,
[h3 . _] then if decimal_scan(h3) is
{
failure then print("Argument <how many> has not been recognized as an integer.\n\n"),
success(n) then
make_files(w,h,n)
}
}
}
}
}
}.