File tree Expand file tree Collapse file tree
external_library/java/hype Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ load_library :hype
2+ include_package 'hype'
3+ java_import 'hype.extended.layout.HGridLayout'
4+ # string color array
5+ PALETTE = %w(
6+ CLEAR
7+ WHITE
8+ BLACK
9+ LGREY
10+ GREY
11+ DGREY
12+ RED
13+ GREEN
14+ BLUE
15+ CYAN
16+ YELLOW
17+ MAGENTA
18+ ) . freeze
19+ # format string see fill below
20+ FSTRING = 'H::%s' . freeze
21+
22+ def settings
23+ size ( 640 , 640 )
24+ end
25+
26+ def setup
27+ sketch_title 'Color Presets'
28+ H . init ( self )
29+ H . background ( color ( '#242424' ) )
30+ grid = HGridLayout . new ( 3 ) . spacing ( 210 , 157 ) . start_loc ( 10 , 10 )
31+ PALETTE . each do |col |
32+ H . add ( HRect . new ( 200 , 147 ) )
33+ . stroke_weight ( 3 )
34+ . stroke ( H ::BLACK , 150.0 ) # Note we call hype constants
35+ . fill ( instance_eval ( format ( FSTRING , col ) ) ) # and using eval
36+ . loc ( grid . get_next_point )
37+ end
38+ end
39+
40+ def draw
41+ H . draw_stage
42+ no_loop
43+ end
You can’t perform that action at this time.
0 commit comments