Skip to content

Commit 6355071

Browse files
committed
--add-opens experiments
1 parent 18d15d6 commit 6355071

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env jruby -v -W2
2+
# frozen_string_literal: true
3+
require 'propane'
4+
5+
# The Colorist class
6+
class ColorField < Propane::App
7+
load_library :hype
8+
%w[H HDrawablePool HSphere].freeze.each do |klass|
9+
java_import "hype.#{klass}"
10+
end
11+
java_import 'hype.extended.colorist.HColorField'
12+
java_import 'hype.extended.layout.HGridLayout'
13+
14+
attr_reader :color_field, :pool
15+
POOL_COLS = 9
16+
POOL_ROWS = 7
17+
POOL_DEPTH = 9
18+
19+
def settings
20+
size(640, 640, P3D)
21+
end
22+
23+
def setup
24+
sketch_title 'Color Field Example'
25+
H.init(self)
26+
H.background(color('#242424'))
27+
H.use3D(true)
28+
@color_field = HColorField.new(width, height)
29+
.add_point(-300, 0, color('#FF0066'), 0.6)
30+
.add_point(width - 300, 0, color('#3300FF'), 0.6)
31+
.fill_only
32+
# .strokeOnly
33+
# .fillAndStroke
34+
@pool = HDrawablePool.new(POOL_COLS * POOL_ROWS * POOL_DEPTH)
35+
pool.auto_add_to_stage
36+
.add(HSphere.new)
37+
.layout(HGridLayout.new.start_x(-600).start_y(-450).start_z(-600).spacing(150, 150, 150).rows(POOL_ROWS).cols(POOL_COLS))
38+
.on_create do |obj|
39+
obj.size(40).stroke_weight(0).no_stroke.fill(0).anchor_at(H::CENTER)
40+
end
41+
.requestAll
42+
end
43+
44+
def draw
45+
pool.each do |d|
46+
d.fill(0)
47+
color_field.apply_color(d)
48+
end
49+
lights
50+
sphere_detail(10)
51+
push_matrix
52+
translate(width / 2, height / 2, -800)
53+
rotate_y(frame_count.radians)
54+
H.draw_stage
55+
pop_matrix
56+
end
57+
end
58+
59+
ColorField.new
Lines changed: 38 additions & 0 deletions
Loading
Lines changed: 28 additions & 0 deletions
Loading
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/sun.java2d.opengl=ALL-UNNAMED

0 commit comments

Comments
 (0)