File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env jruby
2+ require 'propane'
3+ require 'ruby_wordcram'
4+
5+ # Literate colors from propane
6+ # uses `web_to_color_array` to create a hash of fruity colors
7+ # to join two words as `cherry\ red` use back slash
8+ class Fruits < Propane ::App
9+
10+ PALETTE = %w( #b2c248 #c40000 #a61733 #f7ca18 #32cd23 #ffc800 #f27935 #ffe5b4 #913d88 #f22613 #c72c48 #ff43a4 ) . freeze
11+ FRUITS = %w( avocado cherry\ red cranberry lemon lime mango orange peach plum pomegranate raspberry strawberry ) . freeze
12+
13+ def settings
14+ size 600 , 480
15+ end
16+
17+ def setup
18+ sketch_title 'Fruity Colors'
19+ background ( 255 )
20+ colors = FRUITS . zip ( web_to_color_array ( PALETTE ) ) . to_h
21+ longest = FRUITS . max { |a , b | a . length <=> b . length }
22+ shortest = FRUITS . min { |a , b | a . length <=> b . length }
23+ words = FRUITS . map do |fruit |
24+ weight = norm_strict ( fruit . length , longest . length , shortest . length )
25+ word = Word . new ( fruit , weight )
26+ word . set_font ( create_font ( data_path ( 'MINYN___.TTF' ) , 1 ) )
27+ word . set_color ( colors [ fruit ] )
28+ end
29+ WordCram . new ( self )
30+ . from_words ( words . to_java ( Word ) )
31+ . sized_by_weight ( 20 , 80 )
32+ . draw_all
33+ end
34+ end
35+
36+ Fruits . new
You can’t perform that action at this time.
0 commit comments