Skip to content

Commit d4505d6

Browse files
committed
various eb color fixes
1 parent ba9910e commit d4505d6

17 files changed

+115
-123
lines changed

demo/arc_tesselation.rb

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setup
2121
sketch_title 'Arc Tesselation'
2222
# create a java primitive array of signed int
2323
# @cols = web_to_color_array(PALETTE)
24-
@group = ColorGroup.from_web_array(PALETTE.to_java(:string))
24+
@group = ColorGroup.from_web_array(PALETTE)
2525
@cols = group.colors
2626
stroke_weight 1.5
2727
stroke_cap SQUARE
@@ -72,8 +72,6 @@ def mouse_pressed
7272
puts group.ruby_string # prints out current web colors as an array of String
7373
end
7474

75-
76-
7775
def key_typed
7876
case key
7977
when 'c', 'C'

demo/fading.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ class Fading < Processing::App
55

66
NUM_ELEM = 100
77
PALETTE = %w[#F58F12 #0B9EE7 #4EA731 #F4D910 #F334E3 #202020]
8-
attr_reader :my_dots, :frm, :save_anim, :group
8+
attr_reader :my_dots, :frm, :save_anim, :colors
99

1010
def setup
1111
sketch_title 'Fading Arcs'
12-
@group = ColorGroup.from_web_array(PALETTE.to_java(:string)
13-
colors = group.colors
14-
background(group.last)
12+
@colors = web_to_color_array(PALETTE)
13+
background(colors.last)
1514
no_stroke
1615
@save_anim = false
1716
@my_dots = (0..NUM_ELEM).map do
@@ -25,7 +24,7 @@ def setup
2524
end
2625

2726
def draw
28-
fill(group.last, 10)
27+
fill(colors.last, 10)
2928
rect(0, 0, width, height)
3029
my_dots.each(&:display)
3130
return unless save_anim

demo/recursive_pentagon.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ def setup
99
sketch_title 'Recursive Pentagons'
1010
@strut_factor = 0.2
1111
@renderer = GfxRender.new g # so we can send Vec2D :to_vertex
12-
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
13-
@cols = group.colors
12+
@cols = web_to_color_array(PALETTE)
1413
no_loop
1514
end
1615

external_library/java/hype/color_pool.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class ColorPool < Processing::App
88
end
99
%w[colorist.HColorPool layout.HGridLayout].freeze.each do |klass|
1010
java_import "hype.extended.#{klass}"
11-
end
11+
end
1212

1313
PALETTE = %w[#FFFFFF #F7F7F7 #ECECEC #0095A8 #00616F #333333 #FF3300 #FF6600].freeze
1414

@@ -20,8 +20,8 @@ def setup
2020
sketch_title 'Color Pool'
2121
H.init(self)
2222
H.background(color('#242424'))
23-
color_group = ColorGroup.from_web_array(PALETTE.to_java(:string)
24-
colors = HColorPool.new(color_group.colors)
23+
24+
colors = HColorPool.new(web_to_color_array(PALETTE))
2525
pool = HDrawablePool.new(15_876)
2626
pool.auto_add_to_stage
2727
.add(HRect.new(5))

external_library/java/hype/color_pool_wovns.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def setup
2121
sketch_title 'Color Pool Wovns'
2222
H.init(self)
2323
H.background(color('#242424'))
24-
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
25-
colors = HColorPool.new(group.colors)
24+
group = web_to_color_array(PALETTE)
25+
colors = HColorPool.new(web_to_color_array(PALETTE))
2626
pool = HDrawablePool.new(15_876)
2727
pool.auto_add_to_stage
2828
.add(HRect.new(50))

external_library/java/hype/h_orbiter.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def settings
2020

2121
def setup
2222
sketch_title('HOrbiter Example')
23-
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
23+
group = web_to_color_array(PALETTE)
2424
H.init(self)
2525
H.background(color('#242424'))
2626
H.use3D(true)
@@ -34,7 +34,7 @@ def setup
3434
@pool = HDrawablePool.new(100)
3535
pool.autoAddToStage
3636
.add(HSphere.new)
37-
.colorist(HColorPool.new(group.colors).fill_only)
37+
.colorist(HColorPool.new(web_to_color_array(PALETTE)).fill_only)
3838
.on_create do |obj|
3939
ran_size = 10 + (rand(0..3) * 7)
4040
obj.size(ran_size).stroke_weight(0).no_stroke.anchor_at(H::CENTER)

external_library/java/hype/h_oscillator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def setup
2323
.cols(90)
2424
pool.auto_add_to_stage
2525
.add(HRect.new(6).rounding(10).anchor_at(H::CENTER).no_stroke)
26-
.colorist(HColorPool.new(ColorGroup.from_web_array(PALETTE.to_java(:string)).colors))
26+
.colorist(HColorPool.new(web_to_color_array(PALETTE)))
2727
.layout(layout)
2828
.on_create do |obj|
2929
i = pool.current_index

external_library/java/hype/h_rotate.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def settings
1515
def setup
1616
sketch_title 'HRotate'
1717
H.init(self)
18-
@colors = ColorGroup.from_web_array(PALETTE.to_java(:string)).colors
18+
@colors = web_to_color_array(PALETTE)
1919
H.background(colors[0])
2020
H.use3D(true)
2121
# rotate on the x axis

external_library/java/hype/h_sprite.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def setup
2525
.add(HSprite.new(50,50).texture(HImage.new(data_path('tex1.png'))))
2626
.add(HSprite.new(50,50).texture(HImage.new(data_path('tex2.png'))))
2727
.add(HSprite.new(50,50).texture(HImage.new(data_path('tex3.png'))))
28-
.colorist(HColorPool.new(ColorGroup.from_web_array(PALETTE.to_java(:string)).colors).fill_only)
28+
.colorist(HColorPool.new(web_to_color_array(PALETTE)).fill_only)
2929
.on_create do |obj|
3030
i = pool.current_index
3131
obj.anchorAt(H::CENTER).rotation(45)

external_library/java/hype/hype_swarm.rb

+49-48
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
require 'picrate'
22

3-
# The sketch class
43
class HypeSwarm < Processing::App
5-
load_library :hype, :color_group
6-
java_import 'hype.interfaces.HLocatable'
7-
HYPE = %w[H HDrawablePool HCanvas HRect].freeze
8-
hype_format = 'hype.%s'
9-
HYPE.each { |klass| java_import format(hype_format, klass) }
10-
EXTENDED = %w[
11-
colorist.HColorPool behavior.HSwarm behavior.HTween behavior.HTimer
12-
].freeze
13-
hype_extended_format = 'hype.extended.%s'
14-
EXTENDED.each { |klass| java_import format(hype_extended_format, klass) }
4+
load_library :hype
5+
include_package 'hype'
6+
# Access through Hype namespace
7+
module Hype
8+
java_import 'hype.extended.behavior.HSwarm'
9+
java_import 'hype.extended.behavior.HTimer'
10+
java_import 'hype.extended.behavior.HTween'
11+
java_import 'hype.extended.colorist.HColorPool'
12+
java_import 'hype.interfaces.HLocatable'
13+
end
14+
15+
PALETTE = %w[#FFFFFF #F7F7F7 #ECECEC #333333 #0095a8 #00616f #FF3300 #FF6600].freeze
16+
PALETTE2 = %w[#242424 #111111 #ECECEC].freeze
17+
include Hype
1518

16-
PALETTE = %w(#FFFFFF #F7F7F7 #ECECEC #333333 #0095a8 #00616f #FF3300 #FF6600).freeze
17-
PALETTE2 = %w(#242424 #111111 #ECECEC).freeze
1819
attr_reader :swarm, :canvas, :colors, :pool, :tween, :count
1920

2021
def settings
@@ -25,63 +26,63 @@ def setup
2526
sketch_title 'Hype Swarm'
2627
H.init(self)
2728
@count = 0
28-
color_group = ColorGroup.from_web_array(PALETTE.to_java(:string))
29-
@colors = HColorPool.new(color_group.colors)
30-
colors2 = ColorGroup.from_web_array(PALETTE2.to_java(:string)).colors
29+
@colors = HColorPool.new(web_to_color_array(PALETTE))
30+
colors2 = web_to_color_array(PALETTE2)
3131
H.background(colors2[0])
3232
H.add(@canvas = HCanvas.new.auto_clear(false).fade(40))
3333
@swarm = HSwarm.new
34-
.speed(4)
35-
.turn_ease(0.1)
36-
.twitch(15)
37-
.idle_goal(width / 2, height / 2)
34+
.speed(4)
35+
.turn_ease(0.1)
36+
.twitch(15)
37+
.idle_goal(width / 2, height / 2)
3838
@pool = HDrawablePool.new(10)
3939
pool.auto_add_to_stage
40-
.add(HRect.new(10).rounding(5))
41-
.on_create do |obj|
42-
obj.stroke_weight(2)
43-
.stroke(colors2[2])
44-
.fill(colors2[1])
45-
.loc(rand(100..540), rand(100..540))
46-
.anchor_at(H::CENTER)
47-
.rotation(45)
48-
@tween = HTween.new
49-
.target(obj).property(H::LOCATION)
50-
.start(obj.x, obj.y)
51-
.end(rand(0..width), rand(0..height))
52-
.ease(0.01)
53-
.spring(0.9)
54-
on_anim = proc do
55-
tween.start(obj.x, obj.y)
56-
.end(rand(100..540), rand(100..540))
57-
.ease(0.01)
58-
.spring(0.9)
59-
.register
60-
end
40+
.add(HRect.new(10).rounding(5))
41+
.on_create do |obj|
42+
obj.stroke_weight(2)
43+
.stroke(colors2[1])
44+
.fill(colors2[2])
45+
.loc(rand(100..540), rand(100..540))
46+
.anchor_at(H::CENTER)
47+
.rotation(45)
48+
@tween = HTween.new
49+
.target(obj).property(H::LOCATION)
50+
.start(obj.x, obj.y)
51+
.end(rand(0..width), rand(0..height))
52+
.ease(0.01)
53+
.spring(0.9)
54+
on_anim = proc do
55+
tween.start(obj.x, obj.y)
56+
.end(rand(100..540), rand(100..540))
57+
.ease(0.01)
58+
.spring(0.9)
59+
.register
60+
end
6161
HTimer.new.interval(2_000).callback(&on_anim)
6262
end
63-
.request_all
63+
.request_all
6464
end
6565

6666
def draw
6767
if count < 100
6868
swarm.add_target(
6969
canvas.add(
7070
HRect.new(8, 2)
71-
.rounding(4)
72-
.anchor_at(H::CENTER)
73-
.no_stroke
74-
.fill(colors.get_color)
71+
.rounding(4)
72+
.anchor_at(H::CENTER)
73+
.no_stroke
74+
.fill(colors.get_color)
7575
)
7676
)
7777
@count += 1
7878
end
7979
H.draw_stage
8080
it = swarm.goals.iterator
81-
while it.has_next?
81+
while it.has_next
8282
it.remove
83-
# it.next
83+
it.next
8484
end
85+
8586
pool.each do |d|
8687
swarm.add_goal(d.x, d.y)
8788
end

external_library/java/hype/magnetic_field.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require 'picrate'
22

3-
# The sketch class
43
class MagneticField < Processing::App
54

65
load_library :hype
7-
%w[H HDrawablePool HRect HShape].freeze.each do |klass|
6+
%w[H HRect HShape HDrawablePool].freeze.each do |klass|
87
java_import "hype.#{klass}"
98
end
10-
%w[layout.HGridLayout behavior.HMagneticField behavior.HSwarm].freeze.each do |klass|
9+
10+
%w[behavior.HMagneticField behavior.HSwarm layout.HGridLayout].freeze.each do |klass|
1111
java_import "hype.extended.#{klass}"
1212
end
1313

external_library/java/hype/polar_layout.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ def settings
2121
def setup
2222
sketch_title 'Polar Layout'
2323
H.init(self)
24-
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
25-
@colors = HColorPool.new(group.colors)
24+
@colors = HColorPool.new(web_to_color_array(PALETTE))
2625
H.background(group.last)
2726
H.use3D(true)
2827
@ranSeedNum = 1

external_library/java/hype/proximity.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ def settings
2222

2323
def setup
2424
sketch_title 'Hype Proximity'
25-
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
26-
@colors = KEY.zip(group.colors).to_h
25+
@colors = KEY.zip(web_to_color_array(PALETTE)).to_h
2726
H.init(self)
2827
H.background(colors[:background])
2928
canvas = H.add(HCanvas.new.auto_clear(false).fade(5))

external_library/java/hype/random_trigger.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def settings
2020

2121
def setup
2222
sketch_title 'Random Trigger'
23-
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
24-
col = KEY.zip(group.colors).to_h
23+
group = web_to_color_array(PALETTE)
24+
col = KEY.zip(web_to_color_array(PALETTE)).to_h
2525
H.init(self)
2626
H.background(col[:background])
2727
# Create a new randTrigger with a 1 in 15 chance

external_library/java/hype/rotate_gear.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def settings
1717
def setup
1818
sketch_title 'HRotate Gears'
1919
H.init(self)
20-
color_group = ColorGroup.from_web_array(PALETTE.to_java(:string))
21-
@colors = color_group.colors
20+
color_group = web_to_color_array(PALETTE)
21+
@colors = web_to_color_array(PALETTE)
2222
H.background(colors[0])
2323
svg1 = HShape.new(data_path('cog_sm.svg'))
2424
svg2 = HShape.new(data_path('cog_lg.svg'))

0 commit comments

Comments
 (0)