From fd38d4096e65ba5afba8ed1ddc75ed1814ca8c16 Mon Sep 17 00:00:00 2001 From: Rubén Beltran del Río Date: Tue, 26 Jun 2018 22:00:10 +0000 Subject: Update Documentation --- doc/README.md | 261 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 doc/README.md (limited to 'doc') diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..c1054cd --- /dev/null +++ b/doc/README.md @@ -0,0 +1,261 @@ +## Classes + +
+
TomatoSauceEventEmitter
+
+
+ +## Members + +
+
Util : Object
+

Module containing utility functions

+
+
+ +## Functions + +
+
256ColorsRenderer()
+

Returns a 256 color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors +for more info.

+
+
ANSIRenderer()
+

Returns a basic ansi color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors +for more info.

+
+
FakeColorRenderer()
+

Returns a malformed 24-bit ansi color

+
+
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

+
+
CircleScreen()
+

Draws concentric circles. Each ring has its own color.

+
+
GradientsScreen()
+

Draws moving gradient boxes

+
+
MirrorsScreen()
+

Draws small moving gradient boxes and repeats them.

+
+
RandomScreen()
+

Draws random colors

+
+
SprinklesScreen()
+

Draws random sprinkles in the screen each frame. Same color per +frame.

+
+
+ +## Interfaces + +
+
IScreenString
+

A function that represents a screen, it is called frequently and should +return a string consisting of commands to run.

+
+
IRendererString
+

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.

+
+
+ + + +## IScreen ⇒ String +A function that represents a screen, it is called frequently and should +return a string consisting of commands to run. + +**Kind**: global interface +**Returns**: String - The commands used to render the screen elements + +| Param | Type | Description | +| --- | --- | --- | +| modulation | Number | A number between 0 and 255 representing the current step of the modulation | +| width | Number | The width of the screen | +| height | Number | The height of the screen | +| renderer | [IRenderer](#IRenderer) | The renderer used to colorize the scfeen | + + + +## IRenderer ⇒ String +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**: String - The commands used to colorize the terminal + +| Param | Type | Description | +| --- | --- | --- | +| red | Number | The red component of the color between 0 and 255 | +| green | Number | The green component of the color between 0 and 255 | +| blue | Number | The green component of the color between 0 and 255 | + + + +## TomatoSauce ⇐ EventEmitter +**Kind**: global class +**Extends**: EventEmitter +**Properties** + +| Name | Type | Default | Description | +| --- | --- | --- | --- | +| screens | [Array.<IScreen>](#IScreen) | | an array of screens available to serve | +| renderers | [Array.<IRenderer>](#IRenderer) | | an array of renderers available to colorize | +| [port] | Number | 9999 | the port to listen on | +| [frequency] | Number | 333 | how often to update the screen | +| [modulation] | Number | 5 | number between 0-255 depicting current modulation step | + + +* [TomatoSauce](#TomatoSauce) ⇐ EventEmitter + * [new TomatoSauce(config)](#new_TomatoSauce_new) + * [.run()](#TomatoSauce+run) + + + +### 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 | object | the configuration object used to extend the properties. | + + + +### tomatoSauce.run() +Main entry point, initializes the server and binds events for connections + +**Kind**: instance method of [TomatoSauce](#TomatoSauce) + + +## Util : Object +Module containing utility functions + +**Kind**: global variable + +* [Util](#Util) : Object + * [.parse16BitBuffer(buffer)](#Util.parse16BitBuffer) ⇒ Number + * [.pickRandom(array)](#Util.pickRandom) ⇒ Any + * [.loadFiles(path)](#Util.loadFiles) ⇒ Array + + + +### Util.parse16BitBuffer(buffer) ⇒ Number +Parses a 16 bit number buffer + +**Kind**: static method of [Util](#Util) +**Returns**: Number - the parsed value + +| Param | Type | Description | +| --- | --- | --- | +| buffer | Array.<String> | the buffer to parse | + + + +### Util.pickRandom(array) ⇒ Any +Picks a random element from an array + +**Kind**: static method of [Util](#Util) +**Returns**: Any - the picked element + +| Param | Type | Description | +| --- | --- | --- | +| array | Array | the array to use | + + + +### Util.loadFiles(path) ⇒ Array +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 [Util](#Util) +**Returns**: Array - the array of all the loaded modules + +| Param | Type | Description | +| --- | --- | --- | +| path | String | the path where the files are located | + + + +## 256ColorsRenderer() +Returns a 256 color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors +for more info. + +**Kind**: global function +**Implements**: [IRenderer](#IRenderer) + + +## ANSIRenderer() +Returns a basic ansi color, see https://en.wikipedia.org/wiki/ANSI_escape_code#Colors +for more info. + +**Kind**: global function +**Implements**: [IRenderer](#IRenderer) + + +## FakeColorRenderer() +Returns a malformed 24-bit ansi color + +**Kind**: global function +**Implements**: [IRenderer](#IRenderer) + + +## 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**: [IRenderer](#IRenderer) + + +## CircleScreen() +Draws concentric circles. Each ring has its own color. + +**Kind**: global function +**Implements**: [IScreen](#IScreen) + + +## GradientsScreen() +Draws moving gradient boxes + +**Kind**: global function +**Implements**: [IScreen](#IScreen) + + +## MirrorsScreen() +Draws small moving gradient boxes and repeats them. + +**Kind**: global function +**Implements**: [IScreen](#IScreen) + + +## RandomScreen() +Draws random colors + +**Kind**: global function +**Implements**: [IScreen](#IScreen) + + +## SprinklesScreen() +Draws random sprinkles in the screen each frame. Same color per +frame. + +**Kind**: global function +**Implements**: [IScreen](#IScreen) -- cgit