#!/usr/bin/ruby1.8
#
# $Id: lc2003lt.rb,v 1.20 2003/11/02 13:43:10 knok Exp $

require 'color'
require 'ming/ming'
require 'bgshape'
require 'illumtext'
require 'starout'
require 'pagehandle'
include Ming

pg = PageHandle.new('lc2003lt')

def nagoya(font, color, bgcolor)
  dim = [80, 80]
  max = 20
  s = SWFSprite.new
  bg = BgShape.new(bgcolor, dim)
  s.add(bg.shape)
  t = SWFText.new
  t.set_font(font)
  t.set_height(20)
  t.set_color(color.red, color.green, color.blue)
  t.move_to(- t.get_width('名')/2, t.get_ascent/2)
  t.add_string('名')
  ti = s.add(t)
  0.upto(max) do |mul|
    ti.move_to(dim[0]/2 - (dim[0]/2/max) * mul, (dim[0]/max) * mul)
    ti.scale_to(0.1 + (1.0/max)*mul)
    s.next_frame
  end
  s.remove(ti)
  s.next_frame
  t = SWFText.new
  t.set_font(font)
  t.set_height(20)
  t.set_color(color.red, color.green, color.blue)
  t.move_to(- t.get_width('古')/2, t.get_ascent/2)
  t.add_string('古')
  ti = s.add(t)
  0.upto(max) do |mul|
    ti.move_to(dim[0]/2, (dim[0]/max) * mul)
    ti.scale_to(0.1 + (1.0/max)*mul)
    s.next_frame
  end
  s.remove(ti)
  s.next_frame
  t = SWFText.new
  t.set_font(font)
  t.set_height(20)
  t.set_color(color.red, color.green, color.blue)
  t.move_to(- t.get_width('屋')/2, t.get_ascent/2)
  t.add_string('屋')
  ti = s.add(t)
  0.upto(max) do |mul|
    ti.move_to(dim[0]/2 + (dim[0]/2/max) * mul, (dim[0]/max) * mul)
    ti.scale_to(0.1 + (1.0/max)*mul)
    s.next_frame
  end
  s.remove(ti)
  s.next_frame
end

dim = [400, 400]
tsize = 40
m = SWFMovie.new
m.set_dimension(dim[0], dim[1])
m.set_rate(75)
SWFFont.font_path.push "/usr/share/libming/fonts/"
mincho = SWFFont.new('KochiGMincho.fdb')

black = Color.new(0, 0, 0)
white = Color.new(255, 255, 255)
m.set_background(white.red, white.green, white.blue)
bg = BgShape.new(black, dim)
btn = bg.setResume()
#btn = bg.setNext('http://localhost/')
m.add(btn)
bgitem = m.add(bg.shape)

# title
title = IllumText.new(m, dim, 5)
str = "Flashによるプレゼンテーション"
title.setrightuptext(str, 25, mincho, white)
m.next_frame

0.upto(30) do |i|
  title.iteration
  m.next_frame
end

msleep(m, 10)
name1 = m.add(centertext('野首貴嗣', 20, mincho, white))
name2 = m.add(centertext('knok@daionet.gr.jp', 18, mincho, white))
name1.move_to(200, 280)
name2.move_to(200, 320)
8.downto(0) do |mul|
  name1.add_color(-mul * 32, -mul * 32, -mul * 32)
  name2.add_color(-mul * 32, -mul * 32, -mul * 32)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

# fadeout
star = StarOut.new(m, dim, bgitem)
star.setstars(30, white)
0.upto(40) do |mul|
  star.iteration()
  m.next_frame
end

m.add(pg.action(pg.next))
m.next_frame

# save
m.save(pg.cur)
pg.iteration

# 2nd slide
# fade in
mincho = SWFFont.new('KochiGMincho.fdb')
m = SWFMovie.new
m.set_dimension(dim[0], dim[1])
m.set_rate(75)
m.set_background(white.red, white.green, white.blue)
bg = BgShape.new(black, dim)
btn = bg.setResume()
btn.add_action(pg.action(pg.prev), key_press('b'))
m.add(btn)
bgitem = m.add(bg.shape)
title = IllumText.new(m, dim, 5)
title.setrightuptext("Flashとは", 25, mincho, white)
title.setoffsetloc(title.textlen, 20)
#title.setoffsetloc(200, 200)
m.next_frame

16.downto(-16) do |mul|
  title.iteration
  bgitem.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

line = SWFShape.new()
line.set_line(2, white.red, white.green, white.blue)
line.move_pen_to(0, 0)
line.draw_line_to(dim[0], 0)
lineobj = m.add(line)
lineobj.move_to(0, 25)

8.downto(0) do |mul|
  lineobj.add_color(-16*mul, -16*mul, -16*mul)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('時に嫌われもの', 20, mincho, white))
para1.move_to(10, 45)
m.add(SWFAction.new('stop();'))
m.next_frame

img1 = m.add(SWFBitmap.new("swf-w3m.jpg"))
img1.move_to(10, 60)
para1 = m.add(lefttext('w3mでみれねーYO!', 15, mincho, white))
para1.move_to(200, 75)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('時には人気者', 20, mincho, white))
para1.move_to(10, 120)
m.add(SWFAction.new('stop();'))
m.next_frame
spr1 = m.add(nagoya(mincho, black, white))
spr1.move_to(30, 140)
para1 = m.add(lefttext('名古屋はええよ', 15, mincho, white))
para1.move_to(200, 180)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(centertext('まあともかく軽量な動画形式です', 25, mincho, white))
para1.move_to(200, 270)
m.add(SWFAction.new('stop();'))
m.next_frame

# fadeout
star = StarOut.new(m, dim, bgitem)
star.setstars(30, white)
0.upto(40) do |mul|
  col = star.iteration()
  img1.add_color(col.red, col.green, col.blue)
  spr1.add_color(col.red, col.green, col.blue)
  m.next_frame
end

m.add(pg.action(pg.next))
m.next_frame

m.save(pg.cur)
pg.iteration

# 3rd slide
mincho = SWFFont.new('KochiGMincho.fdb')
m = SWFMovie.new
m.set_dimension(dim[0], dim[1])
m.set_rate(75)
m.set_background(white.red, white.green, white.blue)
bg = BgShape.new(black, dim)
btn = bg.setResume()
btn.add_action(pg.action(pg.prev), key_press('b'))
m.add(btn)
bgitem = m.add(bg.shape)
title = IllumText.new(m, dim, 5)
title.setrightuptext("プレゼンに使おう", 25, mincho, white)
title.setoffsetloc(title.textlen, 20)
m.next_frame

16.downto(-16) do |mul|
  title.iteration
  bgitem.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

line = SWFShape.new()
line.set_line(2, white.red, white.green, white.blue)
line.move_pen_to(0, 0)
line.draw_line_to(dim[0], 0)
lineobj = m.add(line)
lineobj.move_to(0, 25)

8.downto(0) do |mul|
  lineobj.add_color(-16*mul, -16*mul, -16*mul)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('行指向のデータなんて...', 20, mincho, white))
para1.move_to(10, 45)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('XMLはちょっと...', 20, mincho, white))
para1.move_to(10, 150)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('S式も勘弁して下さい', 20, mincho, white))
para1.move_to(10, 240)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(centertext('というわけでFlash', 25, mincho, white))
para1.move_to(200, 340)
m.add(SWFAction.new('stop();'))
m.next_frame

star = StarOut.new(m, dim, bgitem)
star.setstars(30, white)
0.upto(40) do |mul|
  col = star.iteration()
#  img1.add_color(col.red, col.green, col.blue)
#  img2.add_color(col.red, col.green, col.blue)
#  img3.add_color(col.red, col.green, col.blue)
  m.next_frame
end

m.add(pg.action(pg.next))
m.next_frame

m.save(pg.cur)
pg.iteration

# 4th slide
mincho = SWFFont.new('KochiGMincho.fdb')
m = SWFMovie.new
m.set_dimension(dim[0], dim[1])
m.set_rate(75)
m.set_background(white.red, white.green, white.blue)
bg = BgShape.new(black, dim)
btn = bg.setResume()
btn.add_action(pg.action(pg.prev), key_press('b'))
m.add(btn)
bgitem = m.add(bg.shape)
title = IllumText.new(m, dim, 5)
title.setrightuptext("何がいいの?", 25, mincho, white)
title.setoffsetloc(title.textlen, 20)
m.next_frame

16.downto(-16) do |mul|
  title.iteration
  bgitem.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

line = SWFShape.new()
line.set_line(2, white.red, white.green, white.blue)
line.move_pen_to(0, 0)
line.draw_line_to(dim[0], 0)
lineobj = m.add(line)
lineobj.move_to(0, 25)

8.downto(0) do |mul|
  lineobj.add_color(-16*mul, -16*mul, -16*mul)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('自由なエフェクトかけまくり', 20, mincho, white))
para1.move_to(10, 45)
para1 = m.add(lefttext('大抵のブラウザでみられる', 20, mincho, white))
para1.move_to(10, 70)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('w3mな人はごめんなさい', 15, mincho, white))
para1.move_to(25, 90)
img1 = m.add(SWFBitmap.new("swf2-w3m.jpg"))
img1.move_to(25, 110)
img1.scale_to(0.6)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('でもpptよりはマシだよね', 15, mincho, white))
para1.move_to(25, 160)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('フォントも埋め込み', 20, mincho, white))
para1.move_to(10, 190)
para1 = m.add(lefttext('ライセンスに注意', 15, mincho, white))
para1.move_to(25, 210)
m.add(SWFAction.new('stop();'))
m.next_frame

# fadeout
star = StarOut.new(m, dim, bgitem)
star.setstars(30, white)
0.upto(40) do |mul|
  col = star.iteration()
  img1.add_color(col.red, col.green, col.blue)
  m.next_frame
end

m.add(pg.action(pg.next))
m.next_frame

m.save(pg.cur)
pg.iteration

# 4th slide
mincho = SWFFont.new('KochiGMincho.fdb')
m = SWFMovie.new
m.set_dimension(dim[0], dim[1])
m.set_rate(75)
m.set_background(white.red, white.green, white.blue)
bg = BgShape.new(black, dim)
btn = bg.setResume()
btn.add_action(pg.action(pg.prev), key_press('b'))
m.add(btn)
bgitem = m.add(bg.shape)
title = IllumText.new(m, dim, 5)
title.setrightuptext("でも困ることも...", 25, mincho, white)
title.setoffsetloc(title.textlen, 20)
m.next_frame

16.downto(-16) do |mul|
  title.iteration
  bgitem.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

line = SWFShape.new()
line.set_line(2, white.red, white.green, white.blue)
line.move_pen_to(0, 0)
line.draw_line_to(dim[0], 0)
lineobj = m.add(line)
lineobj.move_to(0, 25)

8.downto(0) do |mul|
  lineobj.add_color(-16*mul, -16*mul, -16*mul)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('データ作成 == プログラミング', 20, mincho, white))
para1.move_to(10, 45)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('mgpやultrapointの方がずっと楽', 15, mincho, white))
para1.move_to(25, 70)
img1 = m.add(SWFBitmap.new("mingruby.jpg"))
img1.move_to(25, 90)
img1.scale_to(0.5)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('カコイイeffectは難しい', 20, mincho, white))
para1.move_to(10, 210)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('ゲーセンにいってパクりまくり', 15, mincho, white))
para1.move_to(25, 280)
m.add(SWFAction.new('stop();'))
m.next_frame

# fadeout
star = StarOut.new(m, dim, bgitem)
star.setstars(30, white)
0.upto(40) do |mul|
  col = star.iteration()
  img1.add_color(col.red, col.green, col.blue)
#  img2.add_color(col.red, col.green, col.blue)
#  img3.add_color(col.red, col.green, col.blue)
  m.next_frame
end

m.add(pg.action(pg.next))
m.next_frame

m.save(pg.cur)
pg.iteration

# 6th slide
mincho = SWFFont.new('KochiGMincho.fdb')
m = SWFMovie.new
m.set_dimension(dim[0], dim[1])
m.set_rate(75)
m.set_background(white.red, white.green, white.blue)
bg = BgShape.new(black, dim)
btn = bg.setResume()
btn.add_action(pg.action(pg.prev), key_press('b'))
m.add(btn)
bgitem = m.add(bg.shape)
title = IllumText.new(m, dim, 5)
title.setrightuptext("利用事例", 25, mincho, white)
title.setoffsetloc(title.textlen, 20)
m.next_frame

16.downto(-16) do |mul|
  title.iteration
  bgitem.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

line = SWFShape.new()
line.set_line(2, white.red, white.green, white.blue)
line.move_pen_to(0, 0)
line.draw_line_to(dim[0], 0)
lineobj = m.add(line)
lineobj.move_to(0, 25)

8.downto(0) do |mul|
  lineobj.add_color(-16*mul, -16*mul, -16*mul)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('Debian 10th quiz', 20, mincho, white))
para1.move_to(10, 45)
img1 = m.add(SWFBitmap.new("debian10th.jpg"))
img1.move_to(25, 60)
img1.scale_to(0.5)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('そこそこ好評', 15, mincho, white))
para1.move_to(170, 100)
para1 = m.add(lefttext('問題そのものを考える方が重要', 15, mincho, white))
para1.move_to(170, 120)
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(lefttext('実は!', 20, mincho, white))
para1.move_to(0, 200)

25.downto(10) do |mul|
  para1.scale_to(0.1 * mul)
  m.next_frame
end
m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(centertext('前のスライドに戻ることができなかったんだ!', 18, mincho, white))
para1.move_to(200, 230)
img2 = m.add(SWFBitmap.new("kibayashi.jpg"))
img2.move_to(75, 250)
img2.scale_to(0.6)
m.add(SWFAction.new('stop();'))
m.next_frame

m.remove(para1)
m.remove(img2)
para1 = m.add(centertext('なんだってー!', 30, mincho, white))
para1.move_to(200, 230)
img2 = m.add(SWFBitmap.new("nandatte-.jpg"))
img2.move_to(60, 260)
img2.scale_to(0.8)
m.add(SWFAction.new('stop();'))
m.next_frame

# fadeout
star = StarOut.new(m, dim, bgitem)
star.setstars(30, white)
0.upto(40) do |mul|
  col = star.iteration()
  img1.add_color(col.red, col.green, col.blue)
  img2.add_color(col.red, col.green, col.blue)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

para1 = m.add(centertext('全ては遅すぎたんだ...', 30, mincho, black))
para1.move_to(200, 200)

16.downto(0) do |mul|
  para1.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

0.upto(16) do |mul|
  para1.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

m.add(pg.action(pg.next))
m.next_frame

m.save(pg.cur)
pg.iteration

# 7th slide
mincho = SWFFont.new('KochiGMincho.fdb')
m = SWFMovie.new
m.set_dimension(dim[0], dim[1])
m.set_rate(75)
m.set_background(white.red, white.green, white.blue)
bg = BgShape.new(black, dim)
btn = bg.setResume()
btn.add_action(pg.action(pg.prev), key_press('b'))
m.add(btn)
bgitem = m.add(bg.shape)
para1 = m.add(centertext("ともかく貴様ら、", 30, mincho, white))
para1.move_to(200, 170)
para1 = m.add(centertext("もっとフラッシュプレゼンを", 30, mincho, white))
para1.move_to(200, 210)
para1 = m.add(centertext("流行らせるべきです", 30, mincho, white))
para1.move_to(200, 250)
m.next_frame

16.downto(-16) do |mul|
  title.iteration
  bgitem.add_color(16*mul, 16*mul, 16*mul)
  m.next_frame
end

m.add(SWFAction.new('stop();'))
m.next_frame

pg.done
m.add(pg.action(pg.next))
m.next_frame

m.save(pg.cur)
pg.iteration

__END__
