1 // This file is part of the FXT library.
2 // Copyright (C) 2012, 2013, 2014 Joerg Arndt
3 // License: GNU General Public License version 3 or later,
4 // see the file COPYING.txt in the main directory.
5 
6 #include "fxtio.h"
7 #include "fxttypes.h"
8 
9 #include "jjassert.h"
10 
11 
12 void
print_composition_aa(const ulong * a,ulong m)13 print_composition_aa(const ulong *a, ulong m)
14 // Render composition as ASCII art.
15 {
16     cout << endl;
17 
18     --a;  // make one-based
19 
20     ulong mx = 0;
21     for (ulong j=1; j<=m; ++j)
22         if ( a[j] > mx )  mx = a[j];
23 
24     for (ulong k=mx; k>0; --k)
25     {
26         cout << ' ';
27 
28         ulong kl = 0;  // last occurrence of element >=k
29         for (ulong j=1; j<=m; ++j)
30             if ( a[j]>=k )  kl = j;
31 
32         for (ulong j=1; j<=kl; ++j)
33         {
34             cout << ( a[j] >= k ? 'o' : ' ' );
35         }
36         cout << endl;
37     }
38 }
39 // -------------------------
40 
41 void
print_fountain_aa(const ulong * a,ulong m)42 print_fountain_aa(const ulong *a, ulong m)
43 // Render composition as fountain of coin ASCII art.
44 {
45 
46     cout << endl;
47 
48     --a;  // make one-based
49 
50     ulong mx = 0;  // max value
51     for (ulong j=1; j<=m; ++j)
52         if ( a[j] > mx )  mx = a[j];
53 
54     for (ulong k=mx; k>0; --k)
55     {
56         cout << ' ';
57 
58         ulong kl = 0;  // last occurrence of element >=k
59         for (ulong j=1; j<=m; ++j)
60             if ( a[j]>=k )  kl = j;
61 
62         for (ulong j=0; j<=mx-k; ++j)  cout << ' ';  // fountain
63         for (ulong j=1; j<=kl; ++j)
64         {
65             cout << ' ';  // fountain
66             cout << ( a[j] >= k ? 'O' : ' ' );
67         }
68         cout << endl;
69     }
70 }
71 // -------------------------
72