Skip to content

Instantly share code, notes, and snippets.

@duskvirkus
Last active July 25, 2019 22:11
Show Gist options
  • Save duskvirkus/a4330f7a177f76d529b181823749b645 to your computer and use it in GitHub Desktop.
Save duskvirkus/a4330f7a177f76d529b181823749b645 to your computer and use it in GitHub Desktop.
Processing sketch with command line arguments for width and height. (Only tested on Linux)
// Visual Studio Code tasks.json for the sketch
// Uses Processing VS code extension (https://github.com/TobiahZ/processing-vscode)
// Width and Height are hard coded in this file for rapid prototyping.
// Ctrl + Shift + B to Run
{
"version": "2.0.0",
"tasks": [
{
"label": "All",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"command": "echo",
"presentation": {
"reveal": "always",
"focus": false,
"panel": "shared",
},
"args": [
"Running Clean, Build, and Run Tasks",
],
"dependsOrder": "sequence",
"dependsOn": [
"Clean",
"Build",
"Run"
]
},{
"label": "Clean",
"type": "shell",
"group": "build",
"command": "rm",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
},
"args": [
"-rf",
"${workspaceRoot}/out",
],
},{
"label": "Build",
"type": "shell",
"group": "build",
"command": "${config:processing.path}",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
},
"args": [
"--force",
"--sketch=${workspaceRoot}",
"--output=${workspaceRoot}/out",
"--export"
],
},{
"label": "Run",
"type": "shell",
"group": "build",
"command": "${workspaceRoot}/out/${workspaceFolderBasename}",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
},
"args": [
"512",
"512",
]
}
]
}
void settings() {
int argWidth = 0;
int argHeight = 0;
String usage = "Usage width(int) height(int)";
if (args == null || args.length != 2) {
println(usage);
exit();
}
try {
argWidth = Integer.parseInt(args[0]);
argHeight = Integer.parseInt(args[1]);
} catch (NumberFormatException e) {
println(usage);
exit();
}
size(argWidth, argHeight);
}
void setup() {
}
void draw() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment