Sha256: b418d83e9cc9da0fd3114efe1ef9274ef338019875aab1b633036e8265a2cd44
Contents?: true
Size: 850 Bytes
Versions: 6
Compression:
Stored size: 850 Bytes
Contents
require 'ruby-processing' # Click into the window to give it focus and press the letter keys # to create forms in time and space. Each key has a unique identifying # number called it's ASCII value. These numbers can be used to position # shapes in space. class Keyboard < Processing::App def setup @num_chars = 26 @key_scale = 200.0 / @num_chars-1.0 @rect_width = width/4 no_stroke background 0 end def draw if key_pressed? if key >= ("A"[0]) && key <= ("z"[0]) if key <= ("Z"[0]) @key_index = key - ("A"[0]) else @key_index = key - ("a"[0]) end fill millis % 255 begin_rect = @rect_width/2 + @key_index * @key_scale - @rect_width/2 rect begin_rect, 0, @rect_width, height end end end end Keyboard.new :title => "Keyboard", :width => 200, :height => 200
Version data entries
6 entries across 6 versions & 1 rubygems