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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
## Classes
<dl>
<dt><a href="#TomatoSauce">TomatoSauce</a> ⇐ <code>EventEmitter</code></dt>
<dd></dd>
</dl>
## Members
<dl>
<dt><a href="#Util">Util</a> : <code>Object</code></dt>
<dd><p>Module containing utility functions</p>
</dd>
</dl>
## Functions
<dl>
<dt><a href="#256ColorsRenderer">256ColorsRenderer()</a></dt>
<dd><p>Returns a 256 color, see <a href="https://en.wikipedia.org/wiki/ANSI_escape_code#Colors">https://en.wikipedia.org/wiki/ANSI_escape_code#Colors</a>
for more info.</p>
</dd>
<dt><a href="#ANSIRenderer">ANSIRenderer()</a></dt>
<dd><p>Returns a basic ansi color, see <a href="https://en.wikipedia.org/wiki/ANSI_escape_code#Colors">https://en.wikipedia.org/wiki/ANSI_escape_code#Colors</a>
for more info.</p>
</dd>
<dt><a href="#FakeColorRenderer">FakeColorRenderer()</a></dt>
<dd><p>Returns a malformed 24-bit ansi color</p>
</dd>
<dt><a href="#TrueColorRenderer">TrueColorRenderer()</a></dt>
<dd><p>Returns an ANSI code for 24-bit True Color, see
<a href="https://en.wikipedia.org/wiki/ANSI_escape_code#Colors">https://en.wikipedia.org/wiki/ANSI_escape_code#Colors</a> and look for
24-bit colors for more info. Only looks good in supported terminals,
otherwise looks like FakeColor</p>
</dd>
<dt><a href="#CircleScreen">CircleScreen()</a></dt>
<dd><p>Draws concentric circles. Each ring has its own color.</p>
</dd>
<dt><a href="#GradientsScreen">GradientsScreen()</a></dt>
<dd><p>Draws moving gradient boxes</p>
</dd>
<dt><a href="#MirrorsScreen">MirrorsScreen()</a></dt>
<dd><p>Draws small moving gradient boxes and repeats them.</p>
</dd>
<dt><a href="#RandomScreen">RandomScreen()</a></dt>
<dd><p>Draws random colors</p>
</dd>
<dt><a href="#SprinklesScreen">SprinklesScreen()</a></dt>
<dd><p>Draws random sprinkles in the screen each frame. Same color per
frame.</p>
</dd>
</dl>
## Interfaces
<dl>
<dt><a href="#IScreen">IScreen</a> ⇒ <code>String</code></dt>
<dd><p>A function that represents a screen, it is called frequently and should
return a string consisting of commands to run.</p>
</dd>
<dt><a href="#IRenderer">IRenderer</a> ⇒ <code>String</code></dt>
<dd><p>A function that represents a renderer, it should take in a color in RGB and
return a string with the appropriate code to colorize the terminal.</p>
</dd>
</dl>
<a name="IScreen"></a>
## IScreen ⇒ <code>String</code>
A function that represents a screen, it is called frequently and should
return a string consisting of commands to run.
**Kind**: global interface
**Returns**: <code>String</code> - The commands used to render the screen elements
| Param | Type | Description |
| --- | --- | --- |
| modulation | <code>Number</code> | A number between 0 and 255 representing the current step of the modulation |
| width | <code>Number</code> | The width of the screen |
| height | <code>Number</code> | The height of the screen |
| renderer | [<code>IRenderer</code>](#IRenderer) | The renderer used to colorize the scfeen |
<a name="IRenderer"></a>
## IRenderer ⇒ <code>String</code>
A function that represents a renderer, it should take in a color in RGB and
return a string with the appropriate code to colorize the terminal.
**Kind**: global interface
**Returns**: <code>String</code> - The commands used to colorize the terminal
| Param | Type | Description |
| --- | --- | --- |
| red | <code>Number</code> | The red component of the color between 0 and 255 |
| green | <code>Number</code> | The green component of the color between 0 and 255 |
| blue | <code>Number</code> | The green component of the color between 0 and 255 |
<a name="TomatoSauce"></a>
## TomatoSauce ⇐ <code>EventEmitter</code>
**Kind**: global class
**Extends**: <code>EventEmitter</code>
**Properties**
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| screens | [<code>Array.<IScreen></code>](#IScreen) | | an array of screens available to serve |
| renderers | [<code>Array.<IRenderer></code>](#IRenderer) | | an array of renderers available to colorize |
| [port] | <code>Number</code> | <code>9999</code> | the port to listen on |
| [frequency] | <code>Number</code> | <code>333</code> | how often to update the screen |
| [modulation] | <code>Number</code> | <code>5</code> | number between 0-255 depicting current modulation step |
* [TomatoSauce](#TomatoSauce) ⇐ <code>EventEmitter</code>
* [new TomatoSauce(config)](#new_TomatoSauce_new)
* [.run()](#TomatoSauce+run)
<a name="new_TomatoSauce_new"></a>
### new TomatoSauce(config)
The main application for tomato sauce. Listens for connections and serves
random combinations of screens and renderers
The main entry point is the `#run()` function.
It emits a listening event that contains the server information on
the `server` key inside the `data` property of the event.
It also emits an error event that contains the error information on
the `error` key inside the `data` property of the event.
| Param | Type | Description |
| --- | --- | --- |
| config | <code>object</code> | the configuration object used to extend the properties. |
<a name="TomatoSauce+run"></a>
### tomatoSauce.run()
Main entry point, initializes the server and binds events for connections
**Kind**: instance method of [<code>TomatoSauce</code>](#TomatoSauce)
<a name="Util"></a>
## Util : <code>Object</code>
Module containing utility functions
**Kind**: global variable
* [Util](#Util) : <code>Object</code>
* [.parse16BitBuffer(buffer)](#Util.parse16BitBuffer) ⇒ <code>Number</code>
* [.pickRandom(array)](#Util.pickRandom) ⇒ <code>Any</code>
* [.loadFiles(path)](#Util.loadFiles) ⇒ <code>Array</code>
<a name="Util.parse16BitBuffer"></a>
### Util.parse16BitBuffer(buffer) ⇒ <code>Number</code>
Parses a 16 bit number buffer
**Kind**: static method of [<code>Util</code>](#Util)
**Returns**: <code>Number</code> - the parsed value
| Param | Type | Description |
| --- | --- | --- |
| buffer | <code>Array.<String></code> | the buffer to parse |
<a name="Util.pickRandom"></a>
### Util.pickRandom(array) ⇒ <code>Any</code>
Picks a random element from an array
**Kind**: static method of [<code>Util</code>](#Util)
**Returns**: <code>Any</code> - the picked element
| Param | Type | Description |
| --- | --- | --- |
| array | <code>Array</code> | the array to use |
<a name="Util.loadFiles"></a>
### Util.loadFiles(path) ⇒ <code>Array</code>
For a gi ven path, requires all of the files and returns an array
with the results. If the directory contains any non-requireable
files, it will fail.
**Kind**: static method of [<code>Util</code>](#Util)
**Returns**: <code>Array</code> - the array of all the loaded modules
| Param | Type | Description |
| --- | --- | --- |
| path | <code>String</code> | the path where the files are located |
<a name="256ColorsRenderer"></a>
## 256ColorsRenderer()
Returns a 256 color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
for more info.
**Kind**: global function
**Implements**: [<code>IRenderer</code>](#IRenderer)
<a name="ANSIRenderer"></a>
## ANSIRenderer()
Returns a basic ansi color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
for more info.
**Kind**: global function
**Implements**: [<code>IRenderer</code>](#IRenderer)
<a name="FakeColorRenderer"></a>
## FakeColorRenderer()
Returns a malformed 24-bit ansi color
**Kind**: global function
**Implements**: [<code>IRenderer</code>](#IRenderer)
<a name="TrueColorRenderer"></a>
## TrueColorRenderer()
Returns an ANSI code for 24-bit True Color, see
https://en.wikipedia.org/wiki/ANSI_escape_code#Colors and look for
24-bit colors for more info. Only looks good in supported terminals,
otherwise looks like FakeColor
**Kind**: global function
**Implements**: [<code>IRenderer</code>](#IRenderer)
<a name="CircleScreen"></a>
## CircleScreen()
Draws concentric circles. Each ring has its own color.
**Kind**: global function
**Implements**: [<code>IScreen</code>](#IScreen)
<a name="GradientsScreen"></a>
## GradientsScreen()
Draws moving gradient boxes
**Kind**: global function
**Implements**: [<code>IScreen</code>](#IScreen)
<a name="MirrorsScreen"></a>
## MirrorsScreen()
Draws small moving gradient boxes and repeats them.
**Kind**: global function
**Implements**: [<code>IScreen</code>](#IScreen)
<a name="RandomScreen"></a>
## RandomScreen()
Draws random colors
**Kind**: global function
**Implements**: [<code>IScreen</code>](#IScreen)
<a name="SprinklesScreen"></a>
## SprinklesScreen()
Draws random sprinkles in the screen each frame. Same color per
frame.
**Kind**: global function
**Implements**: [<code>IScreen</code>](#IScreen)
|