Skip to content

Commit 5ba49e7

Browse files
committed
glitch example
1 parent 2352c7b commit 5ba49e7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Example for an artificial glitch effect.
2+
# Move the mouse from left to right to see different intensity
3+
# or press the left mouse button to see the original image.
4+
#
5+
# Author: Nick 'Milchreis' Müller
6+
# Translated to JRubyArt by Martin Prout
7+
8+
load_library :ImageProcessing
9+
java_import 'milchreis.imageprocessing.Glitch'
10+
11+
attr_reader :my_image
12+
13+
def setup
14+
sketch_title 'Glitch'
15+
# Load image
16+
@my_image = load_image(data_path('example.jpg'))
17+
end
18+
19+
def draw
20+
return image(my_image, 0, 0) if mouse_pressed?
21+
intensity = map1d(mouseX, 0..width, 0..4)
22+
image(Glitch.apply(my_image, intensity), 0, 0)
23+
# You can also use:
24+
# Glitch.apply(image)
25+
# Glitch.apply(image, intensity, scanlineHeight)
26+
end
27+
28+
def settings
29+
size(550, 550)
30+
end

0 commit comments

Comments
 (0)