7 You will need [Node.js][node] installed, at least version 8. Install
8 dependencies by running `npm install` from the root of the project
9 and start the server by running `npm start`. It will listen on port 9999
12 ## Configuration variables
14 Tomato Sauce can be configured using env variables:
16 * `TOMATO_SAUCE_PORT`: The port to listen on. Defauts to 9999.
17 * `TOMATO_SAUCE_FREQUENCY`: How often it will send a screen in
18 miliseconds. Defaults to 333.
19 * `TOMATO_SAUCE_MODULATION`: How much the modulation counter will
20 increase per round. Defaults to 5.
21 * `TOMATO_SAUCE_SCREEN_PATH`: Path from which we will load screens. It
22 defaults to `{project_root}/lib/screens`
23 * `TOMATO_SAUCE_RENDERER_PATH`: Path from which we will load renderers. It
24 defaults to `{project_root}/lib/renderers`
26 ## Make your own screens
28 A screen is a function that will receive a modulation value from 0-255,
29 the width of the viewport, the height of the viewport, and a renderer
30 function, and it returns a string that consists of the commands that
31 will be sent to the socket.
33 * `IScreen(modulation <int>, width <int>, height <int>, renderer
34 <IRenderer>) -> payload <string>`
36 It should output the required commands that telnet needs to move the
37 cursor and draw. For convenience, a renderer function is passed so
38 calculating color should not be a part of the screen, just moving the
39 cursor around and calling specific colors.
41 ## Make your own renderers
43 The included renderers are wrappers to some common ways of obtaining
44 colors in the terminal: ANSI, 256 colors, 24-bit colors, and a fake
45 color string that uses incorrect color strings to generate random
48 You can build your own renderer by building a function that receives a
49 red, green, and blue component from 0 to 255 and returns the escape
50 codes to generate the color.
52 * `IRenderer(red <int>, green <int>, blue <int>) ->
57 The binary just serves as a wrapper to read configuration, and as a
58 bridge to the console. It consumes `lib/tomato_sauce`. All configuration
59 is optional, and should be passed as an object on instantiation. The
60 instance is an event emitter that will emit a `listening` event with
61 the server data, and an `error` event in case something goes wrong.
64 const TomatoSauce = require('tomato-sauce');
66 const tomatoSauce = new TomatoSauce(config);
68 tomatoSauce.on('listening', () => {
70 const address = event.data.server.address();
71 console.log(`Tomato Sauce listening on: ${address.address}:${address.port}`);
74 tomatoSauce.on('error', (error) => {
82 ### Configuration Values
84 The config object should be a simple object with these keys (All are
87 * `port`: The port to listen on (Defaults to 9999)
88 * `frequency`: How often we'll send a new frame in milliseconds
90 * `modulation`: How fast the modulation counter will be increased
92 * `screens`: An array containing the screen functions (Defaults to [])
93 * `renderers`: An array containing the renderer functions (Defaults to [])
95 [node]: https://nodejs.org/en/