LoginSignup
0
0

More than 5 years have passed since last update.

RubyKokubanで画像を拡大アニメーションさせる

Posted at

mrubyを使ってインタラクティブアプリケーションを作ることが出来ます。
インストール方法はこちらをどうぞ。 → [最新記事]

画像を拡大アニメーションさせてみます。

def update
  @scale ||= 0.0
  @scale += 0.05
  @scale = 0.0 if @scale > 3.0
end

def draw
  @image ||= Image.load("sample.png")
  set_color(Color::White)
  @image.draw(0, 0, @image.width * @scale, @image.height * @scale)
end

update関数で@scaleメンバを増加させ、Image.drawにパラメータとして渡しています。

$ kokuban exec image003.rb

@scaleのリミット値や変更速度を操作して遊んでみましょう。

image004.png

目次

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0