Processingでつくったものを画像(静止画)に書き出す方法を確認しました。
「keyPressed()」を使って、以下のような画像を書き出します。
コードはこちら↓です。
最後の「def keyPressed():」部分で、キーボードの「s」を押すとpngが書き出されるようになっています。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup(): | |
size(500,500) | |
def draw(): | |
background(200) | |
ellipse(width/2,height/2,60,60) | |
def keyPressed(): | |
if key=='s': | |
saveFrame('0920-01.png') |
gist内のコードの色が変わりません。。
*
最近、Pythonを勉強しています。
基礎から始めているのですが、基礎だけでは面白くないのでProcessingをPython版にしてデザインやアートと絡めつつ楽しんで勉強しています。
Python版のProcessingもほとんど同じですね。
Java版の「void」、JavaScript版の「function」の部分が、Python版では「def」に変えるくらいでほぼ同じです。