Processingのvscode開発環境を構築(Mac)
Processing の IDE が非常にイヤなので,まずはQiita: Processing を Visual Studio Code で動かしたいを参照し設定する。しかしこの記事のやり方だと,1 スケッチ毎に.vscodeによる設定をしなければならずイヤなので,例えばProcessing でゼロから学ぶプログラミング・ビジュアルアートの公式リポジトリなんかを clone してきて試す時に,プロジェクトフォルダに内包されている複数のスケッチを即時実行できるように改良したメモです。
準備
まずは上述のQiita 記事通りにセッティングを行う。そしたら Processing のインストール。ラクなのでHomebrewを使う。
install.sh
1# homebrew 2if !(type "brew" > /dev/null 2>&1); then 3 echo "install HomeBrew..." 4 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null ; brew install caskroom/cask/brew-cask 2> /dev/null 5 6else 7 echo "Homebrew is already installed" 8fi 9 10if !(type "processing-java" > /dev/null 2>&1); then 11 brew tap caskroom/cask 12 brew install brew-cask 13 echo "installing Processing via Homebrew..." 14 brew cask install -v processing 15 16 echo "Open Processing and install processing-java (from menu bar > Tools > install processing-java)" 17 echo "input path to Processing.app: " 18 read pjpath 19 echo "adding path" 20 sudo ln -s ${pjpath}/processing-java /usr/local/bin/ 21else 22 pjpath=$(which processing-java) 23 echo "processing-java is already installed : ${pjpath}" 24fi 25 26echo "add path to vscode setting (tasks.json)" 27sed -i -e "s|\"command\":.*|\"command\": \"${pjpath}\",|g" .vscode/tasks.json
そして,生成・編集されたtasks.jsonの"args"の"--sketch"部分を,visualstudio.com: Variables Referenceを頼りに編集する。
.vscode/tasks.json
1"--sketch=${workspaceRoot}/${relativeFileDirname}"
これによりスケッチフォルダのパスがちゃんと渡される。
Variable Reference
1${workspaceFolder} - the path of the folder opened in VS Code 2${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/) 3${file} - the current opened file 4${relativeFile} - the current opened file relative to workspaceFolder 5${relativeFileDirname} - the current opened file's dirname relative to workspaceFolder 6${fileBasename} - the current opened file's basename 7${fileBasenameNoExtension} - the current opened file's basename with no file extension 8${fileDirname} - the current opened file's dirname 9${fileExtname} - the current opened file's extension 10${cwd} - the task runner's current working directory on startup 11${lineNumber} - the current selected line number in the active file 12${selectedText} - the current selected text in the active file 13${execPath} - the path to the running VS Code executable
これにより,プロジェクトフォルダ直下の.pdeでなくても,Command + Shift + Bで実行できる。ウレシイ。
ここで,試しにgit submodule add git@github.com:cocopon/zero-pde.gitをして,Processing でゼロから学ぶプログラミング・ビジュアルアートを試す等すると良いかも。