samples/07_advanced_rendering/03_render_target_viewports/app/main.rb
def button_tech_demo
    x, y, w, h = 460, 160, 300, 50
    state.button        ||= state.new_entity(:button_with_fade)

    # Adds w.half to x and h.half + 10 to y in order to display the text inside the button's borders.
    state.button.label  ||= [x + w.half, y + h.half + 10, "click me and watch me fade", 0, 1]
    state.button.border ||= [x, y, w, h]

    if inputs.mouse.click && inputs.mouse.click.point.inside_rect?(state.button.border) # if mouse is clicked, and clicked inside button's border
      state.button.clicked_at = inputs.mouse.click.created_at # stores the time the click occurred
    end

    outputs.labels << state.button.label
    outputs.borders << state.button.border

    if state.button.clicked_at # if button was clicked (variable has a value and is not nil)

      # The appearance of the button changes for 0.25 seconds after the time the button is clicked at.
      # The color changes (rgb is set to 0, 180, 80) and the transparency gradually changes.
      # Change 0.25 to 1.25 and notice that the transparency takes longer to return to normal.
      outputs.solids << [x, y, w, h, 0, 180, 80, 255 * state.button.clicked_at.ease(0.25.seconds, :flip)]
    end
  end
# Creates a button and outputs it onto the screen using labels and borders.
# If the button is clicked, the color changes to make it look faded.
Creates a button and outputs it onto the screen using labels and borders.
If the button is clicked, the color changes to make it look faded.
Creates a button and outputs it onto the screen using labels and borders . If the button is clicked the color changes to make it look faded .
def button_tech_demo
    x, y, w, h = 460, 160, 300, 50
    state.button        ||= state.new_entity(:button_with_fade)
    state.button.label  ||= [x + w.half, y + h.half + 10, "click me and watch me fade", 0, 1]
    state.button.border ||= [x, y, w, h]
    if inputs.mouse.click && inputs.mouse.click.point.inside_rect?(state.button.border) 
      state.button.clicked_at = inputs.mouse.click.created_at 
    end
    outputs.labels << state.button.label
    outputs.borders << state.button.border
    if state.button.clicked_at 
      outputs.solids << [x, y, w, h, 0, 180, 80, 255 * state.button.clicked_at.ease(0.25.seconds, :flip)]
    end
  end
def button_tech_demo x , y , w , h = 460 , 160 , 300 , 50 state . button ||= state . new_entity ( :button_with_fade ) state . button . label ||= [ x + w . half , y + h . half + 10 , "click me and watch me fade" , 0 , 1 ] state . button . border ||= [ x , y , w , h ] if inputs . mouse . click && inputs . mouse . click . point . inside_rect? ( state . button . border ) state . button . clicked_at = inputs . mouse . click . created_at end outputs . labels << state . button . label outputs . borders << state . button . border if state . button . clicked_at outputs . solids << [ x , y , w , h , 0 , 180 , 80 , 255 * state . button . clicked_at . ease ( 0.25 . seconds , :flip ) ] end end
Creates a button and outputs it onto the screen using labels and borders.
Creates a button and outputs it onto the screen using labels and borders .
# Adds w.half to x and h.half + 10 to y in order to display the text inside the button's borders. # if mouse is clicked, and clicked inside button's border # stores the time the click occurred # if button was clicked (variable has a value and is not nil) # The appearance of the button changes for 0.25 seconds after the time the button is clicked at. # The color changes (rgb is set to 0, 180, 80) and the transparency gradually changes. # Change 0.25 to 1.25 and notice that the transparency takes longer to return to normal.