fork download
  1.  
  2. /*
  3.  * XaoS, a fast portable realtime fractal zoomer
  4.  * Copyright (C) 1996,1997 by
  5.  *
  6.  * Jan Hubicka (hubicka@paru.cas.cz)
  7.  * Thomas Marsh (tmarsh@austin.ibm.com)
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #include <string.h>
  26. static char data[65536 / 2];
  27. int main(int argc, char **argv)
  28. {
  29. int x, y, s, l = 0, l2 = 0, letter;
  30. int skip = 12;
  31. int width = 80;
  32. int shift = 0;
  33. int rnd = 1;
  34. int digit = 0;
  35. char *string = NULL;
  36. FILE *f = NULL;
  37. for (s = 1; s < argc; s++) {
  38. if (s < argc - 1 && !strcmp(argv[s], "-w"))
  39. width = atol(argv[s + 1]), s++;
  40. else if (s < argc - 1 && !strcmp(argv[s], "-s"))
  41. skip = atol(argv[s + 1]), s++;
  42. else if (s < argc - 1 && !strcmp(argv[s], "-t"))
  43. string = argv[s + 1], s++;
  44. else if (s < argc - 1 && !strcmp(argv[s], "-f")) {
  45. f = fopen(argv[s + 1], "r");
  46. if (f == NULL)
  47. perror(argv[s + 1]), exit(1);
  48. s++;
  49. } else if (!strcmp(argv[s], "-r"))
  50. rnd = 0;
  51. else if (!strcmp(argv[s], "-d"))
  52. digit = 1;
  53. else {
  54. printf("Unknown option %s\n\n", argv[s]);
  55. printf("ASCII-art stereogram generator version 1.0 by Jan Hubicka <hubicka@freesoft.cz>\n\n"
  56. "Usage: %s [options] < file\n\n"
  57. "File consist from spaces and digits representing depth\n\n"
  58. "Options:\n"
  59. "-w width Image width (80)\n"
  60. "-s step Size of repeating seqence (12)\n"
  61. "-t text Text used to generate background\n"
  62. "-r Disable random text placement\n"
  63. "-f file Use file as input for raster\n"
  64. "-d Use digits instead of letters\n"
  65. ,argv[0]);
  66. return 1;
  67. }
  68. }
  69. for (y = 0; !feof(stdin); y++) {
  70. l = 0;
  71. l2 = 0;
  72. if (rnd)
  73. shift = rand();
  74. for (x = 0; x < width; x++) {
  75. if (f != NULL) {
  76. if (!l2) {
  77. letter = getc(f);
  78. if (letter == '\n' || letter == EOF)
  79. letter = ' ', l2 = 1;
  80. } else
  81. letter = ' ';
  82. } else
  83. letter = !digit ? rand() % 32 + 'A' : rand() % 10 + '0';
  84. if (!l && x > skip) {
  85. s = getc(stdin);
  86. if (s == ' ')
  87. s = 0;
  88. else if (s == '\n' || s == EOF)
  89. s = 0, l = 1;
  90. else if (s >= '0' && s <= '9')
  91. s = '0' - s;
  92. else
  93. s = -2;
  94. } else
  95. s = 0;
  96. s += skip;
  97. s = x - s;
  98. if (s < 0)
  99. s = string == NULL ? letter : string[(x + shift) % strlen(string)];
  100. else
  101. s = data[s];
  102. data[x] = s;
  103. putc(s, stdout);
  104. }
  105. putc('\n', stdout);
  106. s = 'a';
  107. while (!l && s != EOF && s != '\n')
  108. s = getc(stdin);
  109. s = 'a';
  110. if (f != NULL)
  111. while (!l2 && s != EOF && s != '\n')
  112. s = getc(f);
  113. }
  114. return 0;
  115. }
  116.  
Success #stdin #stdout 0s 1756KB
stdin
                   11111111111111111111111111111111111
                   11111111111111111111111111111111111
                   11112222222222222222222222222211111
                   11112222222222222222222222222211111
                   11112222222222222222222222222211111
                   11112222233333333333333322222211111
                   11112222233333333333333322222211111
                   11112222233334444433333322222211111
                   11112222233334444433333322222211111
                   11112222233334444433333322222211111
                   11112222233333333333333322222211111
                   11112222233333333333333322222211111
                   11112222222222222222222222222211111
                   11112222222222222222222222222211111
                   11112222222222222222222222222211111
                   11111111111111111111111111111111111
                   11111111111111111111111111111111111
stdout
GJTR`KMJN[LSGJTR`KMJN[LSGJTR`KMJN[LSGJTR`KMJN[LSGJTR`KMJN[LSGJTR`KMJN[LSGJTR`KMJ
]KMQ\\SP]UMY]KMQ\\SP]UMY]KMQ\\SPUMY]KMQ\\SPUMY]KMQ\\SPUMY]KMQ\\SPUMMY]KMQ\\SPUMM
ER_J]KUMS\QPER_J]KUMS\QPER_J]KUM\QPER_J]KUM\QPER_J]KUM\QPER_J]KUM\QQPER_J]KUM\QQ
CQE_PSVJ^COJCQE_PSVJ^COJCQE_PSVJCOJCE_PSVJCOJCE_PSVJCOJCE_PSVJJCOJCCE_PSVJJCOJCC
HTXZQDDUTZUXHTXZQDDUTZUXHTXZQDDUZUXHXZQDDUZUXHXZQDDUZUXHXZQDDUUZUXHHXZQDDUUZUXHH
EYZIHVFQ[K`CEYZIHVFQ[K`CEYZIHVFQK`CEZIHVFQK`CEZIHVFQK`CEZIHVFQQK`CEEZIHVFQQK`CEE
EEDHYNWSMFZCEEDHYNWSMFZCEEDHYNWSFZCEDHYNWFZCEDHYNWFZCEDHHYNWFZZCEDHHHYNWFZZCEDHH
ZNFDRGB`JKZVZNFDRGB`JKZVZNFDRGB`KZVZFDRGBKZVZFDRGBKZVZFDDRGBKZZVZFDDDRGBKZZVZFDD
NQAQLHPZQ\X`NQAQLHPZQ\X`NQAQLHPZ\X`NAQLHP\X`NQLHP\\X`NQLLHP\\XX`NQLLLHP\\XX`NQLL
VRMT^C]XN_TPVRMT^C]XN_TPVRMT^C]X_TPVMT^C]_TPVT^C]__TPVT^^C]__TTPVT^^^C]__TTPVT^^
CNH^N\HYWVQMCNH^N\HYWVQMCNH^N\HYVQMCH^N\HVQMC^N\HVVQMC^NN\HVVQQMC^NNN\HVVQQMC^NN
KJ\A[RN\]WNKKJ\A[RN\]WNKKJ\A[RN\WNKK\A[RNWNKK\A[RN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