6 `npm install` and then run ``./bin/server.js`. It will listen on port 9999
9 ## Configuration variables
11 Tomato Sauce can be configured using env variables:
13 * `TOMATO_SAUCE_PORT`: The port to listen on. Defauts to 9999.
14 * `TOMATO_SAUCE_FREQUENCY`: How often it will send a screen in
15 miliseconds. Defaults to 333.
16 * `TOMATO_SAUCE_MODULATION`: How much the modulation counter will
17 increase per round. Defaults to 5.
18 * `TOMATO_SAUCE_SCREEN_PATH`: Path from which we will load screens. It
19 defaults to `{project_root}/lib/screens`
20 * `TOMATO_SAUCE_RENDERER_PATH`: Path from which we will load renderers. It
21 defaults to `{project_root}/lib/renderers`
23 ## Make your own screens
25 A screen is a function that will receive a modulation value from 0-255,
26 the width of the viewport, the height of the viewport, and a renderer
27 function, and it returns a string that consists of the commands that
28 will be sent to the socket.
30 * `TomatoSauce.IScreen(modulation <int>, width <int>, height <int>, renderer
31 <TomatoSauce.IRenderer>) -> payload <string>`
33 It should output the required commands that telnet needs to move the
34 cursor and draw. For convenience, a renderer function is passed so
35 calculating color should not be a part of the screen, just moving the
36 cursor around and calling specific colors.
38 ## Make your own renderers
40 The included renderers are wrappers to some common ways of obtaining
41 colors in the terminal: ANSI, 256 colors, 24-bit colors, and a fake
42 color string that uses incorrect color strings to generate random
45 You can build your own renderer by building a function that receives a
46 red, green, and blue component from 0 to 255 and returns the escape
47 codes to generate the color.
49 * `TomatoSauce.IRenderer(red <int>, green <int>, blue <int>) ->
54 The binary just serves as a wrapper to read configuration, and as a
55 bridge to the console. It consumes `lib/tomato_sauce`. All configuration
56 is optional, and should be passed as an object on instantiation. The
57 instance is an event emitter that will emit a `listening` event with
58 the server data, and an `error` event in case something goes wrong.
61 const TomatoSauce = require('tomato-sauce');
63 const tomatoSauce = new TomatoSauce(config);
65 tomatoSauce.on('listening', function () {
66 const address = event.data.server.address();
67 console.log(`Tomato Sauce listening on: ${address.address}:${address.port}`);
70 tomatoSauce.on('error', function (error) {
76 ### Configuration Values
78 The config object should be a simple object with these keys (All are
81 * `port`: The port to listen on (Defaults to 9999)
82 * `frequency`: How often we'll send a new frame in milliseconds
84 * `modulation`: How fast the modulation counter will be increased
86 * `screens`: An array containing the screen functions (Defaults to [])
87 * `renderers`: An array containing the renderer functions (Defaults to [])