Skip to content

Commit 27472f2

Browse files
committed
polar_layout
1 parent 67b6590 commit 27472f2

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# encoding: utf-8
2+
load_library :hype
3+
include_package 'hype'
4+
java_import 'hype.extended.layout.HPolarLayout'
5+
java_import 'hype.extended.behavior.HOscillator'
6+
java_import 'hype.extended.colorist.HColorPool'
7+
8+
PALETTE = %w(#FFFFFF #F7F7F7 #ECECEC #CCCCCC #999999 #666666 #4D4D4D #333333 #242424 #202020 #111111 #080808 #000000).freeze
9+
attr_reader :pool, :colors, :box_depth
10+
11+
def settings
12+
size(640, 640, P3D)
13+
end
14+
15+
def setup
16+
sketch_title 'PolarLayout'
17+
H.init(self)
18+
H.background(color('#000000'))
19+
H.use3D(true)
20+
@ranSeedNum = 1
21+
@box_depth = 60
22+
@colors = HColorPool.new(web_to_color_array(PALETTE))
23+
layout = HPolarLayout.new(0.7, 0.1).offset(width / 2, height / 2)
24+
@pool = HDrawablePool.new(600)
25+
pool.auto_add_to_stage
26+
.add(HBox.new.depth(box_depth).width(box_depth).height(box_depth))
27+
.layout(layout)
28+
.on_create do |obj|
29+
i = pool.current_index
30+
HOscillator.new.target(obj).property(H::Z).range(-900, 100).speed(1).freq(1).current_step(i)
31+
HOscillator.new.target(obj).property(H::ROTATION).range(-360, 360).speed(0.05).freq(3).current_step(i)
32+
HOscillator.new.target(obj).property(H::ROTATIONX).range(-360, 360).speed(0.3).freq(1).current_step(i * 2)
33+
HOscillator.new.target(obj).property(H::ROTATIONY).range(-360, 360).speed(0.3).freq(1).current_step(i * 2)
34+
HOscillator.new.target(obj).property(H::ROTATIONZ).range(-360, 360).speed(0.5).freq(1).current_step(i * 2)
35+
end
36+
.request_all
37+
end
38+
39+
def draw
40+
lights
41+
i = 0
42+
pool.each do |d|
43+
d.no_stroke.fill(colors.get_color(i * @ranSeedNum))
44+
i += 1
45+
end
46+
@ranSeedNum += 0.5
47+
@ranSeedNum = 1 if @ranSeedNum > 300
48+
H.draw_stage
49+
end

0 commit comments

Comments
 (0)