Skip to content

Commit 6162888

Browse files
committed
fiddling at edge
1 parent b1286ae commit 6162888

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

processing_app/topics/image_processing/blending.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Blending
2-
# by Andres Colubri. Somewhat refactored for JRubyArt by Martin Prout would be
3-
# better in java if constant were enums (we use a ruby hash here)
2+
# by Andres Colubri. Somewhat refactored for JRubyArt by Martin Prout could be
3+
# much better in java if PConstants were enums (we use a ruby hash here)
44
# Images can be blended using one of the 10 blending modes
55
# (currently available only in P2D and P3).
66
# Click to go to cycle through the modes.
@@ -9,22 +9,22 @@
99
# NOTE: THIS EXAMPLE IS IN PROGRESS -- REAS
1010

1111
attr_reader :img1, :img2, :pic_alpha, :sel_mode, :idx
12-
12+
# avoid the lengthy if/else chain of the original by using array and hash
1313
NAMES = %w[
1414
REPLACE BLEND ADD SUBTRACT LIGHTEST DARKEST DIFFERENCE EXCLUSION MULTIPLY SCREEN
1515
].freeze
1616
VALUES = [
1717
REPLACE, BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY
1818
]
19-
FILTERS = VALUES.zip(NAMES).to_h # avoids the need for a lengthy if else chain
19+
FILTERS = VALUES.zip(NAMES).to_h # avoids the lengthy if/else chain of original
2020

2121
def setup
2222
sketch_title 'Blending'
2323
@img1 = load_image(data_path('layer1.jpg'))
2424
@img2 = load_image(data_path('layer2.jpg'))
2525
noStroke
2626
@idx = -1
27-
@sel_mode = REPLACE
27+
@sel_mode = VALUES.first
2828
end
2929

3030
def draw

0 commit comments

Comments
 (0)