Skip to content

Commit 0a3ee74

Browse files
committed
hype grid_layout example
1 parent f7a0765 commit 0a3ee74

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# encoding: utf-8
2+
load_library :hype
3+
include_package 'hype'
4+
java_import 'hype.extended.layout.HGridLayout'
5+
java_import 'hype.extended.behavior.HOscillator'
6+
java_import 'hype.extended.colorist.HColorPool'
7+
8+
attr_reader :pool, :osc, :scale, :r
9+
10+
def settings
11+
size(640, 640, P3D)
12+
end
13+
14+
def setup
15+
sketch_title 'Grid Layout'
16+
H.init(self)
17+
H.background(color('#242424'))
18+
H.use3D(true)
19+
@r = 0
20+
@scale = 0
21+
@osc = HOscillator.new.range(0.2, 2.5).speed(10).freq(2)
22+
@pool = HDrawablePool.new(125)
23+
pool.auto_add_to_stage
24+
.add(HBox.new.depth(25).width(25).height(25))
25+
.layout(
26+
HGridLayout.new
27+
.start_x(180)
28+
.start_y(180)
29+
.start_z(-140)
30+
.spacing(70, 70, 70)
31+
.cols(5)
32+
.rows(5)
33+
)
34+
.request_all
35+
end
36+
37+
def draw
38+
lights
39+
translate(width / 2, height / 2)
40+
rotate_y(r.radians)
41+
translate(-width / 2, -height / 2)
42+
@r += 0.3
43+
i = 0
44+
pool.each do |d|
45+
osc.current_step(frame_count + i * 3).next_raw
46+
@scale = osc.curr
47+
d.depth(25 * scale).width(25 * scale).height(25 * scale)
48+
i += 1
49+
end
50+
H.draw_stage
51+
end

0 commit comments

Comments
 (0)