#!/usr/bin/env ruby
#
# gradientxform.rb -- IKEGAMI Daisuke
# original is http://ming.sourceforge.net/examples/example.php?name=gradientxform
# $Log: gradientxform.rb,v $
# Revision 1.1  2004/11/07 17:34:22  ikegami
# NEWS: version 0.1.7 shipped.
# some bugs are fixed, and it seems work with Ming 0.3beta1.
#

require 'ming/ming'
include Ming

p = SWFMorph.new

g = SWFGradient.new
g.add_entry(0.0, 0, 0, 0)
g.add_entry(0.16, 0xff, 0xff, 0xff)
g.add_entry(0.32, 0, 0, 0)
g.add_entry(0.48, 0xff, 0xff, 0xff)
g.add_entry(0.64, 0, 0, 0)
g.add_entry(0.80, 0xff, 0xff, 0xff)
g.add_entry(1.00, 0, 0, 0)

s = p.get_shape1
f = s.add_fill(g, SWFFill::RADIAL_GRADIENT)
f.scale_to(0.1)
s.set_left_fill(f)
s.move_pen_to(-160, -120)
s.draw_line(320, 0)
s.draw_line(0, 240)
s.draw_line(-320, 0)
s.draw_line(0, -240)

g = SWFGradient.new
g.add_entry(0.0, 0, 0, 0)
g.add_entry(0.16, 0xff, 0, 0)
g.add_entry(0.32, 0, 0, 0)
g.add_entry(0.48, 0, 0xff, 0)
g.add_entry(0.64, 0, 0, 0)
g.add_entry(0.80, 0, 0, 0xff)
g.add_entry(1.00, 0, 0, 0)

s = p.get_shape2
f = s.add_fill(g, SWFFill::RADIAL_GRADIENT)
f.scale_to(0.16)
f.skew_x_to(-0.5)
s.set_left_fill(f)
s.move_pen_to(-160, -120)
s.draw_line(320, 0)
s.draw_line(0, 240)
s.draw_line(-320, 0)
s.draw_line(0, -240)

m = SWFMovie.new
m.set_dimension(320, 240)
i = m.add(p)
i.move_to(160, 120)

n = 0
while n <= 1.001
  i.set_ratio(n)
  m.next_frame
  n += 0.01
end

m.save('gradientxform.swf')
