ofruby 0.3 をリリース - translate, rotate, scale が使えるようになりました

ofruby 0.3 をリリースしました

新機能

実行画面のナビゲーションバーを隠すことで全画面が使えるようになりました(結構大切) 。noise, Math::sin, deg_to_rad, push_matrix, translate, rotate, scale などが使えるようになりました。

  • Hide the navigationBar at executing script
  • noise(x), noise(x, y), noise(x, y, z)
  • Ruby's Math module (sin, cos ..)
  • rad_to_deg, deg_to_rad
  • push_matrix, pop_matrix, translate, rotate
  • dist, dist_squared, clamp, lerp
  • Support a hardware keyboard

ダウンロードはこちらからどうぞ。

電光掲示板

push_matrix, translate, rotate, scale で文字や図形を加工することが出来るようになったので電光掲示板を作ってみました。文字を変更するとiPhoneが自作のスクリーンセーバーになります。

push_matrixが何をしているのかというのはこの辺りが詳しいです(ofPushMatrixで検索)。これ以外にも基本的にopenFramworksやProcessingの概念はそのままofrubyにも使えるはずです。後Rubyのおかげでブロックを利用すればpop_matrixの呼び出しは不要です。

touch_fall.png

ongaeshi/ofruby-sample

TEXT = "Hello, ofruby!"
# TEXT = "abcdefghijklmnopqrstuvwxyzANCDEFGHIJKLMNOPQRSTIVWXYZ1234567890-/:;()&@.,?!'"
TEXT_WIDTH = 8
SCALE = 3
SPEED = 3
COLOR = rand 0xffffff
BACK = 0x000000

def setup
  set_background_hex BACK
  @texts = []
  @texts.push Texter.new(TEXT)
end

def update
  @texts.each { |e| e.update }
end

def draw
    @texts.each { |e| e.draw }
end

class Texter
  def initialize(text)
    @text = text
    @width = text.length * TEXT_WIDTH * SCALE
    @x = 0
    @y = height / 2
    @rot = 0
  end

  def update
    @x += SPEED
    @x = -@width if @x > width + @width
  end

  def draw
    push_matrix do
      translate @x, @y
      scale SCALE, SCALE * 2
      set_color_hex COLOR
      text @text, 0, 0
    end
  end
end

0.4

RubyKaigiでの要望を入れていきたいと思います。今はスクリプトの削除機能を作っています。

f:id:tuto0621:20140924232950p:plain

Links