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