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+ java_import 'hype.extended.behavior.HAttractor'
5+
6+ attr_reader :a , :r , :hf
7+
8+ def settings
9+ size ( 640 , 640 , P3D )
10+ end
11+
12+ def setup
13+ sketch_title 'Attractor'
14+ H . init ( self )
15+ H . background ( color ( '#242424' ) )
16+ H . use3D ( true )
17+ @r = 0
18+ @a = 0
19+ ha = HAttractor . new ( 320 , 320 , 100 , 260 ) . debug_mode ( true )
20+ @hf = ha . get_force ( 0 )
21+ pool = HDrawablePool . new ( 576 )
22+ pool . auto_add_to_stage
23+ . add ( HBox . new . depth ( 10 ) . width ( 10 ) . height ( 10 ) )
24+ . layout (
25+ HGridLayout . new
26+ . start_x ( 26 )
27+ . start_y ( 26 )
28+ . start_z ( 0 )
29+ . spacing ( 26 , 26 , 26 )
30+ . cols ( 24 )
31+ . rows ( 24 )
32+ )
33+ . on_create do |obj |
34+ obj . no_stroke
35+ . fill ( color ( '#ECECEC' ) )
36+ . anchor_at ( H ::CENTER )
37+ ha . add_target ( obj , 20 , 0.5 )
38+ end
39+ . request_all
40+ end
41+
42+ def draw
43+ lights
44+ x = 320 + cos ( a . radians ) * 200
45+ y = 320 + sin ( a . radians ) * 200
46+ @a += 1.0 / 1.4
47+ hf . loc ( x , y , 100 )
48+ translate ( width / 2 , height / 2 )
49+ rotate_y ( r . radians )
50+ translate ( -width / 2 , -height / 2 )
51+ @r += 0.4
52+ H . draw_stage
53+ end
You can’t perform that action at this time.
0 commit comments