Hello World

From Limelight

Jump to: navigation, search

Below are example of Hello World Limelight productions.

Contents

Simplest Possible

Not very impressive.... But it's as simple as it gets.

Directory Structure:

   + hello_world
   | - props.rb

props.rb

__ :text => "Hello, World!

Opening it You've already installed Limelight right?

jruby -S limelight open hello_world

"It Ain't Easy Being Green"

This is a version you don't have to be ashamed of.

There's no change to the directory structure.

props.rb

__ :text => "Hello, World!", :font_size => 50, :text_color => :green
__ :width => 500, :height => 500, :background_color => :black
__ :horizontal_alignment => :center, :vertical_alignment => :center

As you see, it makes extensive use of the __ operator to add options to the root prop.

Here Boy!

The "Hello, World!" text will come when you call. i.e. move to where you click the mouse.

Directory Structure:

   + hello_world
   | - props.rb
   | - styles.rb
   | + players
     | - background.rb

props.rb

__ :name => "background"
label :id => "label", :text => "Hello, World!"

styles.rb

background {
  background_color :black
  width 500
  height 500
}

label {
  float :on
  x 50
  y 50
  font_size 50
  text_color :green  
}

players/background.rb

module Background
  
  def label
    @label = find("label") if @label.nil?
    return @label
  end
  
  def mouse_clicked(e)
    @animation.stop if @animation
    @target_x = e.x
    @target_y = e.y
    @dx = label.style.x.to_i < e.x ? 1 : -1
    @dy = label.style.y.to_i < e.y ? 1 : -1
    
    @animation = animate do
      on_x = label.style.x.to_i == e.x
      on_y = label.style.y.to_i == e.y
      if on_x && on_y
        @animation.stop
      else
        label.style.x = (label.style.x.to_i + @dx).to_s if !on_x
        label.style.y = (label.style.y.to_i + @dy).to_s if !on_y
      end
    end
  end
  
end

More

More wild and wacky Hello World examples are welcome. If you'd like to submit one, email micah at 8th Light dot com.

Personal tools