Skip to content

Commit

Permalink
Merge pull request aduros#686 from bhansconnect/main
Browse files Browse the repository at this point in the history
Add support for Roc in png2src
  • Loading branch information
aduros authored Jan 10, 2024
2 parents e761e81 + 8bcde05 commit d321e12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { program, Option } = require("commander");
const pkg = require('./package.json');
const { supportedIconExtensions } = require('./lib/utils/icon');

const LANGS = ["assemblyscript", "c", "c3", "cpp", "d", "go", "nelua", "nim", "odin", "penne", "porth", "roland", "rust", "wat", "zig"];
const LANGS = ["assemblyscript", "c", "c3", "cpp", "d", "go", "nelua", "nim", "odin", "penne", "porth", "roc", "roland", "rust", "wat", "zig"];
const langOption = new Option("--lang <lang>", "Use the given language")
.env("W4_LANG")
.choices(LANGS);
Expand Down Expand Up @@ -36,6 +36,8 @@ function requireLang (opts) {
return "penne";
} else if (opts.porth) {
return "porth";
} else if (opts.roc) {
return "roc";
} else if (opts.roland) {
return "roland";
} else if (opts.rust) {
Expand Down Expand Up @@ -151,6 +153,7 @@ program.command("png2src <images...>")
.option("--odin", "Generate Odin source (Shorthand for --lang odin)")
.option("--penne", "Generate Penne source (Shorthand for --lang penne)")
.option("--porth", "Generate Porth source (Shorthand for --lang porth)")
.option("--roc", "Generate Roc source (Shorthand for --lang roc)")
.option("--roland", "Generate Roland source (Shorthand for --lang roland)")
.option("--rs, --rust", "Generate Rust source (Shorthand for --lang rust)")
.option("--wat", "Generate WebAssembly Text source (Shorthand for --lang wat)")
Expand Down
13 changes: 13 additions & 0 deletions cli/lib/png2src.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ const {{name}}-flags {{flags}} end // {{flagsHumanReadable}}
const {{name}}-height {{height}} end
const {{name}}-width {{width}} end
{{/sprites}}`,

roc:
`{{#sprites}}
# {{name}} sprite
{{name}}Sprite = Sprite.new {
data: [ {{bytes}} ],
bpp: BPP{{bpp}},
width: {{width}},
height: {{height}},
}
{{/sprites}}`,

roland:
Expand Down Expand Up @@ -308,6 +320,7 @@ The first occurrence of another color is at (${x}, ${y}) and has the value of (R
"flags": flags,
"flagsHumanReadable": flagsHumanReadable,
"bytes": data,
"bpp": bpp,
"firstByte": dataBytes[0],
"restBytes": dataBytes.slice(1).join(','),
"wasmBytes": wasmBytes.join(''),
Expand Down
1 change: 1 addition & 0 deletions site/docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ w4 png2src --lang rust top.png down.png left.png right.png
| --nim | | Generates Nim source |
| --odin | | Generates Odin source |
| --porth | | Generates Porth source |
| --roc | | Generates Roc source |
| --roland | | Generates Roland source |
| --rs | | Generates Rust source |
| --rust | | Same as `--rs` |
Expand Down

0 comments on commit d321e12

Please sign in to comment.