Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions node-sources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
33 changes: 33 additions & 0 deletions node-sources/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# interact with letterbox using nodejs

A small set of modules to send UDP packets that consist of the contents of a node-canvas to the octopus server.

## setup

run `npm install`

## run examples

### render

stuff on canvas and send contents to octopus

- `node render.js [<host>]`

### scan image

load image stuff on canvas and send contents to octopus
preserves the image ratio and scans from top to bottom

- `node scan-image.js <path-to-image> [<host>]`


## convert protobuf schema

There is a shell script to convert the latest .proto file to an es6 module used with all example scripts.
Calling this will output / overwrite [packet.js](./packet.js).

```
./convert-proto.js ../protobuf/schema.proto
```

28 changes: 28 additions & 0 deletions node-sources/convert-proto.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env node

import { readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { argv } from 'node:process';
import { parseSchema } from 'pbjs';

// convert .proto to es6 module

console.log(argv)
const p = resolve(argv[2])
console.log(p)

if (!p.endsWith('.proto')) {
process.exit(1)
}

const raw = readFileSync(p)
console.log(raw.toString())
const replaced = raw.toString().replace(/( \[[^\]]+\])/g, '')
console.log(replaced)

const f = parseSchema(Buffer.from(replaced))
try {
writeFileSync('packet.js', f.toJavaScript({es6:true}))
} catch (e) {
console.error(e)
}
Loading