Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`$ png-to-box2d generate images/castle.png
Converted image in images/castle.png to triangulated shapes in images/castle.png.json
`,
`$ png-to-box2d generate --overwrite --tolerance 5 images/castle.png out/triangles.json
Converted image in images/castle.png to triangulated shapes in out/triangles.json
`,
];
public static flags = {
...BaseCommand.flags,
overwrite: flags.boolean({
char: 'o',
description: 'overwrite the output file if it exists',
default: false,
}),
tolerance: flags.option({
char: 't',
description: `
path tolerance in px where less tolerance means more triangles per shape
see https://mourner.github.io/simplify-js/ for more information
`.trim(),
default: 2.5,
parse: parseFloat,
}),
alpha: flags.option({
char: 'a',
description: `
the percentage of when an alpha value should be seen as part of the background
when set to X, every pixel that has a transparency of at least X% will be seen as part of the background
`.trim(),
default: 25,
parse: parseFloat,
...BaseCommand.flags,
overwrite: flags.boolean({
char: 'o',
description: 'overwrite the output file if it exists',
default: false,
}),
tolerance: flags.option({
char: 't',
description: `
path tolerance in px where less tolerance means more triangles per shape
see https://mourner.github.io/simplify-js/ for more information
`.trim(),
default: 2.5,
parse: parseFloat,
}),
alpha: flags.option({
char: 'a',
description: `
the percentage of when an alpha value should be seen as part of the background
when set to X, every pixel that has a transparency of at least X% will be seen as part of the background
`.trim(),
default: 25,
parse: parseFloat,
}),
path: flags.boolean({
char: 'p',
description: 'include the full paths of the shapes in the generated json file',
default: false,
}),
beautify: flags.boolean({
char: 'b',
description: 'beautify the generated json file',