Sha256: 1367e5cdaad830cfbcc2aeeebeb8cb3749b737b3b2fff2e0b6e79ed56eb91fac

Contents?: true

Size: 852 Bytes

Versions: 10

Compression:

Stored size: 852 Bytes

Contents

# Letters. 
# 
# Draws letters to the screen. This requires loading a font, 
# setting the font, and then drawing the letters.

def setup    
  size 640, 360    
  @font = create_font "Georgia", 24 
  text_font @font
  text_align CENTER, CENTER    
end

def draw    
  background 0  	
  translate 24, 32  	
  x, y = 0.0, 0.0
  gap = 30  
  # ranges -> arrays -> joined!  	
  letters = ("A".."Z").to_a + ("0".."9").to_a  + ("a".."z").to_a
  letters.each do |letter|  	    
    fill 255
    fill 204, 204, 0 if letter =~ /[AEIOU]/
    fill 0, 204, 204 if letter =~ /[aeiou]/
    fill 153 if letter =~ /[0-9]/
    fill 255, 100, 0 if key_pressed? && (letter.downcase.eql? key) 
 		fill 0, 100, 255 if key_pressed? && (letter.upcase.eql? key)  	
    text letter, x, y  		
    x += gap  		
    if x > width - 30
      x = 0
      y += gap
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.6.2 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.6.1 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.6.0 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.5.1 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.5.0 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.4.4 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.4.3 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.4.2 samples/processing_app/basics/typography/letters.rb
ruby-processing-2.4.1 samples/processing_app/basics/typography/letters.rb