NodeBox 日本語ドキュメント

f:id:peroon:20090913160922p:image
図形描画

  • rect()
  • oval()
  • line()
  • arrow()
  • star()
rect(x, y, width, height, roundness=0.0, draw=True)
oval(x, y, width, height, draw=True)
line(x1, y1, x2, y2, draw=True)
arrow(x, y, width, type=NORMAL, draw=True) #type=NORMAL/FORTYFIVE
star(x, y, points=20, outer=100, inner=50, draw=True)


f:id:peroon:20090913163426p:image
パス

  • beginpath()
  • moveto()
  • lineto()
  • curveto()
  • endpath()
  • findpath()
  • drawpath()
  • beginclip()
  • endclip()
  • autoclosepath()
not yet...


変形

  • transform()
  • translate()
  • rotate()
  • scale()
  • skew()
  • push()
  • pop()
  • reset()
transform(mode=CENTER) #mode=CENTER/CORNER
translate(x, y)
rotate(degrees=0, radians=0)
scale(x, y=None)
skew(x, y=None)
push()
pop()
reset() #reset all transformation


f:id:peroon:20090913163830j:image

  • outputmode()
  • colormode()
  • color()
  • fill()
  • nofill()
  • stroke()
  • nostroke()
  • strokewidth()
  • background()
outputmode(mode) #mode=RGB/CMYK
colormode(mode, range=1.0) #mode=RGB/CMYK/HSB
color(r, g, b, a), color(h, s, b, a), color(c, m, y, k, a), color(k, a)
fill(r, g, b, a), fill(h, s, b, a), fill(c, m, y, k, a), fill(k, a), fill(color)
nofill()
stroke(r, g, b, a), stroke(h, s, b, a), stroke(c, m, y, k, a), stroke(k, a), stroke(color)
nostroke()
strokewidth(width)
background(r, g, b, a=1.0), background(h, s, b, a=1.0), background(c, m, y, k, a=1.0)
background(k, a=1.0), background(color), background(None)

background(None)


タイポグラフィ

  • font()
  • fontsize()
  • text()
  • textpath()
  • textwidth()
  • textheight()
  • textmetrics()
  • lineheight()
  • align()
font(fontname, fontsize=None) #(e.g.)font("Helvetica", 35)
fontsize(fontsize)
text(txt, x, y, width=None, height=1000000, outline=False) #height is maximum height
textpath(txt, x, y, width=None, height=1000000) #clip image to text shape
textwidth(txt, width=None) #get text width
textheight(txt, width=None) #"
textmetrics(txt, width=None) #(e.g.)w, h = textmetrics("hello", 30)
lineheight(height=None) #set the line space
align(align=LEFT) #align=LEFT/RIGHT/CENTER/JUSTIFY


f:id:peroon:20090913165710p:image
画像

  • image()
  • imagesize()
image(path, x, y, width=None, height=None, alpha=1.0, data=None)
imagesize(path) #(e.g.)w, h = imagesize("superfolia.jpg")


ユーティリティ

  • size()
  • var()
  • random()
  • choice()
  • grid()
  • open()
  • files()
  • autotext()
size(w, h) #autoset WIDTH, HEIGHT
size(20*cm, 20*cm)
var(name, type, default, min, max) #(e.g.)var("amount", NUMBER, 30, 0, 100)
random(v1=None, v2=None) #0.0~1.0
choice(list)
grid(cols, rows, colsize=1, rowsize=1) #returns an iteratable object...
open(path).read() #read()/readlines()
files(path) #(e.g.)f = files("images/*.jpg")
autotext() #generates random text

var()については以下に詳しく。






f:id:peroon:20090913165026p:image
var()がとても強力だと思っている。
var()を使うと別ウインドウにスライダなどが表示され、
それを動かすことでプログラム中の変数を動的に変更できる。
(追記)と思っていたのだが、var()で変数の値を変更できるのは
not animationのときだけのようだ。draw()を使っている場合、
var()はうまく動かない。アニメーションしつつ、変数の値を変えたかった
私としては残念だ。キーボードに変数の値を割り振るのなら
processingでできる。このbugが取れたらいいのだけれど!
(English ver) var() doesn't work well with draw(). This is bug.
(バグだと報告されている→reference

var(name, NUMBER, default, min, max)
var(name, TEXT, default="hello")
var(name, BOOLEAN)
var(command, BUTTON) #command is function name


このbugが取れないうちは、NodeBoxを使う理由がない。
JRubyによるActionCodingの方がよさそう。
これはRuby+Processing。
コードを書き換えると画面に反映されるActionCoding。
これがしたかった。NodeBoxでできると思っていたのだが、bugで無理。
ActionCodingの動画はこちら→


しかしRubyなのが難点。そこでpythonとprocessingがつながらないか
調べたところ、Jython+Processingによるライブコーディングが可能みたい。
(ライブコーディングという言葉を「コードを書き換えたらプロセスが動いたままで
挙動が変化する」くらいの意味で使っています)
ということでJython+Processingを使いこなせると理想的。参考


ライブコーディングの意味は以下のようにとらえるのが一般的か

ライブ・コーディングは、僕の記憶だと鈴木健さんと洛西一周さんが発案した企画で、優秀なプログラマーがコーディングしている様子をライブで見ながら酒を飲み、ハッカーとの一体感を楽しむという企画。