Skip to content

Commit

Permalink
various eb color fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
monkstone committed Oct 21, 2019
1 parent ba9910e commit d4505d6
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 123 deletions.
4 changes: 1 addition & 3 deletions demo/arc_tesselation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setup
sketch_title 'Arc Tesselation'
# create a java primitive array of signed int
# @cols = web_to_color_array(PALETTE)
@group = ColorGroup.from_web_array(PALETTE.to_java(:string))
@group = ColorGroup.from_web_array(PALETTE)
@cols = group.colors
stroke_weight 1.5
stroke_cap SQUARE
Expand Down Expand Up @@ -72,8 +72,6 @@ def mouse_pressed
puts group.ruby_string # prints out current web colors as an array of String
end



def key_typed
case key
when 'c', 'C'
Expand Down
9 changes: 4 additions & 5 deletions demo/fading.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ class Fading < Processing::App

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

def setup
sketch_title 'Fading Arcs'
@group = ColorGroup.from_web_array(PALETTE.to_java(:string)
colors = group.colors
background(group.last)
@colors = web_to_color_array(PALETTE)
background(colors.last)
no_stroke
@save_anim = false
@my_dots = (0..NUM_ELEM).map do
Expand All @@ -25,7 +24,7 @@ def setup
end

def draw
fill(group.last, 10)
fill(colors.last, 10)
rect(0, 0, width, height)
my_dots.each(&:display)
return unless save_anim
Expand Down
3 changes: 1 addition & 2 deletions demo/recursive_pentagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ def setup
sketch_title 'Recursive Pentagons'
@strut_factor = 0.2
@renderer = GfxRender.new g # so we can send Vec2D :to_vertex
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
@cols = group.colors
@cols = web_to_color_array(PALETTE)
no_loop
end

Expand Down
6 changes: 3 additions & 3 deletions external_library/java/hype/color_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ColorPool < Processing::App
end
%w[colorist.HColorPool layout.HGridLayout].freeze.each do |klass|
java_import "hype.extended.#{klass}"
end
end

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

Expand All @@ -20,8 +20,8 @@ def setup
sketch_title 'Color Pool'
H.init(self)
H.background(color('#242424'))
color_group = ColorGroup.from_web_array(PALETTE.to_java(:string)
colors = HColorPool.new(color_group.colors)

colors = HColorPool.new(web_to_color_array(PALETTE))
pool = HDrawablePool.new(15_876)
pool.auto_add_to_stage
.add(HRect.new(5))
Expand Down
4 changes: 2 additions & 2 deletions external_library/java/hype/color_pool_wovns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def setup
sketch_title 'Color Pool Wovns'
H.init(self)
H.background(color('#242424'))
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
colors = HColorPool.new(group.colors)
group = web_to_color_array(PALETTE)
colors = HColorPool.new(web_to_color_array(PALETTE))
pool = HDrawablePool.new(15_876)
pool.auto_add_to_stage
.add(HRect.new(50))
Expand Down
4 changes: 2 additions & 2 deletions external_library/java/hype/h_orbiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def settings

def setup
sketch_title('HOrbiter Example')
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
group = web_to_color_array(PALETTE)
H.init(self)
H.background(color('#242424'))
H.use3D(true)
Expand All @@ -34,7 +34,7 @@ def setup
@pool = HDrawablePool.new(100)
pool.autoAddToStage
.add(HSphere.new)
.colorist(HColorPool.new(group.colors).fill_only)
.colorist(HColorPool.new(web_to_color_array(PALETTE)).fill_only)
.on_create do |obj|
ran_size = 10 + (rand(0..3) * 7)
obj.size(ran_size).stroke_weight(0).no_stroke.anchor_at(H::CENTER)
Expand Down
2 changes: 1 addition & 1 deletion external_library/java/hype/h_oscillator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup
.cols(90)
pool.auto_add_to_stage
.add(HRect.new(6).rounding(10).anchor_at(H::CENTER).no_stroke)
.colorist(HColorPool.new(ColorGroup.from_web_array(PALETTE.to_java(:string)).colors))
.colorist(HColorPool.new(web_to_color_array(PALETTE)))
.layout(layout)
.on_create do |obj|
i = pool.current_index
Expand Down
2 changes: 1 addition & 1 deletion external_library/java/hype/h_rotate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def settings
def setup
sketch_title 'HRotate'
H.init(self)
@colors = ColorGroup.from_web_array(PALETTE.to_java(:string)).colors
@colors = web_to_color_array(PALETTE)
H.background(colors[0])
H.use3D(true)
# rotate on the x axis
Expand Down
2 changes: 1 addition & 1 deletion external_library/java/hype/h_sprite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def setup
.add(HSprite.new(50,50).texture(HImage.new(data_path('tex1.png'))))
.add(HSprite.new(50,50).texture(HImage.new(data_path('tex2.png'))))
.add(HSprite.new(50,50).texture(HImage.new(data_path('tex3.png'))))
.colorist(HColorPool.new(ColorGroup.from_web_array(PALETTE.to_java(:string)).colors).fill_only)
.colorist(HColorPool.new(web_to_color_array(PALETTE)).fill_only)
.on_create do |obj|
i = pool.current_index
obj.anchorAt(H::CENTER).rotation(45)
Expand Down
97 changes: 49 additions & 48 deletions external_library/java/hype/hype_swarm.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
require 'picrate'

# The sketch class
class HypeSwarm < Processing::App
load_library :hype, :color_group
java_import 'hype.interfaces.HLocatable'
HYPE = %w[H HDrawablePool HCanvas HRect].freeze
hype_format = 'hype.%s'
HYPE.each { |klass| java_import format(hype_format, klass) }
EXTENDED = %w[
colorist.HColorPool behavior.HSwarm behavior.HTween behavior.HTimer
].freeze
hype_extended_format = 'hype.extended.%s'
EXTENDED.each { |klass| java_import format(hype_extended_format, klass) }
load_library :hype
include_package 'hype'
# Access through Hype namespace
module Hype
java_import 'hype.extended.behavior.HSwarm'
java_import 'hype.extended.behavior.HTimer'
java_import 'hype.extended.behavior.HTween'
java_import 'hype.extended.colorist.HColorPool'
java_import 'hype.interfaces.HLocatable'
end

PALETTE = %w[#FFFFFF #F7F7F7 #ECECEC #333333 #0095a8 #00616f #FF3300 #FF6600].freeze
PALETTE2 = %w[#242424 #111111 #ECECEC].freeze
include Hype

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

def settings
Expand All @@ -25,63 +26,63 @@ def setup
sketch_title 'Hype Swarm'
H.init(self)
@count = 0
color_group = ColorGroup.from_web_array(PALETTE.to_java(:string))
@colors = HColorPool.new(color_group.colors)
colors2 = ColorGroup.from_web_array(PALETTE2.to_java(:string)).colors
@colors = HColorPool.new(web_to_color_array(PALETTE))
colors2 = web_to_color_array(PALETTE2)
H.background(colors2[0])
H.add(@canvas = HCanvas.new.auto_clear(false).fade(40))
@swarm = HSwarm.new
.speed(4)
.turn_ease(0.1)
.twitch(15)
.idle_goal(width / 2, height / 2)
.speed(4)
.turn_ease(0.1)
.twitch(15)
.idle_goal(width / 2, height / 2)
@pool = HDrawablePool.new(10)
pool.auto_add_to_stage
.add(HRect.new(10).rounding(5))
.on_create do |obj|
obj.stroke_weight(2)
.stroke(colors2[2])
.fill(colors2[1])
.loc(rand(100..540), rand(100..540))
.anchor_at(H::CENTER)
.rotation(45)
@tween = HTween.new
.target(obj).property(H::LOCATION)
.start(obj.x, obj.y)
.end(rand(0..width), rand(0..height))
.ease(0.01)
.spring(0.9)
on_anim = proc do
tween.start(obj.x, obj.y)
.end(rand(100..540), rand(100..540))
.ease(0.01)
.spring(0.9)
.register
end
.add(HRect.new(10).rounding(5))
.on_create do |obj|
obj.stroke_weight(2)
.stroke(colors2[1])
.fill(colors2[2])
.loc(rand(100..540), rand(100..540))
.anchor_at(H::CENTER)
.rotation(45)
@tween = HTween.new
.target(obj).property(H::LOCATION)
.start(obj.x, obj.y)
.end(rand(0..width), rand(0..height))
.ease(0.01)
.spring(0.9)
on_anim = proc do
tween.start(obj.x, obj.y)
.end(rand(100..540), rand(100..540))
.ease(0.01)
.spring(0.9)
.register
end
HTimer.new.interval(2_000).callback(&on_anim)
end
.request_all
.request_all
end

def draw
if count < 100
swarm.add_target(
canvas.add(
HRect.new(8, 2)
.rounding(4)
.anchor_at(H::CENTER)
.no_stroke
.fill(colors.get_color)
.rounding(4)
.anchor_at(H::CENTER)
.no_stroke
.fill(colors.get_color)
)
)
@count += 1
end
H.draw_stage
it = swarm.goals.iterator
while it.has_next?
while it.has_next
it.remove
# it.next
it.next
end

pool.each do |d|
swarm.add_goal(d.x, d.y)
end
Expand Down
6 changes: 3 additions & 3 deletions external_library/java/hype/magnetic_field.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'picrate'

# The sketch class
class MagneticField < Processing::App

load_library :hype
%w[H HDrawablePool HRect HShape].freeze.each do |klass|
%w[H HRect HShape HDrawablePool].freeze.each do |klass|
java_import "hype.#{klass}"
end
%w[layout.HGridLayout behavior.HMagneticField behavior.HSwarm].freeze.each do |klass|

%w[behavior.HMagneticField behavior.HSwarm layout.HGridLayout].freeze.each do |klass|
java_import "hype.extended.#{klass}"
end

Expand Down
3 changes: 1 addition & 2 deletions external_library/java/hype/polar_layout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def settings
def setup
sketch_title 'Polar Layout'
H.init(self)
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
@colors = HColorPool.new(group.colors)
@colors = HColorPool.new(web_to_color_array(PALETTE))
H.background(group.last)
H.use3D(true)
@ranSeedNum = 1
Expand Down
3 changes: 1 addition & 2 deletions external_library/java/hype/proximity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def settings

def setup
sketch_title 'Hype Proximity'
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
@colors = KEY.zip(group.colors).to_h
@colors = KEY.zip(web_to_color_array(PALETTE)).to_h
H.init(self)
H.background(colors[:background])
canvas = H.add(HCanvas.new.auto_clear(false).fade(5))
Expand Down
4 changes: 2 additions & 2 deletions external_library/java/hype/random_trigger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def settings

def setup
sketch_title 'Random Trigger'
group = ColorGroup.from_web_array(PALETTE.to_java(:string))
col = KEY.zip(group.colors).to_h
group = web_to_color_array(PALETTE)
col = KEY.zip(web_to_color_array(PALETTE)).to_h
H.init(self)
H.background(col[:background])
# Create a new randTrigger with a 1 in 15 chance
Expand Down
4 changes: 2 additions & 2 deletions external_library/java/hype/rotate_gear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def settings
def setup
sketch_title 'HRotate Gears'
H.init(self)
color_group = ColorGroup.from_web_array(PALETTE.to_java(:string))
@colors = color_group.colors
color_group = web_to_color_array(PALETTE)
@colors = web_to_color_array(PALETTE)
H.background(colors[0])
svg1 = HShape.new(data_path('cog_sm.svg'))
svg2 = HShape.new(data_path('cog_lg.svg'))
Expand Down
Loading

0 comments on commit d4505d6

Please sign in to comment.