RubyConf 大会演示:IronRuby 运行在 Silverlight 之上

  • 2007-11-14
  • 本文字数:637 字

    阅读完需:约 2 分钟

RubyConf 大会的演示示例不同于其他 Silverlight 的演示,代码是用 Ruby 语言编写,而非编写 XAML 来呈现 Silverlight 引擎。对此 John Lam 谈到:

class BounceAnimation < AnimationBase
def initialize(scale_transform_element)
@obj = Wpf.build(Storyboard, :name => random_name,
:target_name => scale_transform_element) {

add(DoubleAnimationUsingKeyFrames, :begin_time=>‘00:00:00’,
:target_property => “ScaleX”) {

add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.0’, :value => 0.200)
add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.2’, :value => 0.935)
add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.3’, :value => 0.852)
add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.4’, :value => 0.935)
}

add(DoubleAnimationUsingKeyFrames, :begin_time=>‘00:00:00’,
:target_property => “ScaleY”) {

add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.0’, :value => 0.200)
add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.2’, :value => 0.935)
add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.3’, :value => 0.852)
add(SplineDoubleKeyFrame, :key_time => ‘00:00:00.4’, :value => 0.935)
}
}
end
end

较之编写 XAML,使用 Ruby 语言更为方便直接,并且更易于让人读懂。尽管这些特性在示例中得到展示,但其中小部分特性将在下一个版本 Silverlight 1.1 的 CTP 出现时才可以使用,届时开发者可以在浏览器中运行 IronRuby。