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