Skip to content

Commit f67aee8

Browse files
authored
Create blend_mode.rb
1 parent 57647a7 commit f67aee8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

demo/blend_mode.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
require 'picrate'
4+
5+
class BlendModeSketch < Processing::App
6+
java_import 'com.jogamp.opengl.GL3'
7+
java_import 'com.jogamp.opengl.GLContext'
8+
9+
attr_reader :gl
10+
def setup
11+
sketch_title 'Blend Mode Difference P2D'
12+
noStroke
13+
fill(255)
14+
# DIFFERENCE is not supported in P2D / P3D
15+
# blendMode(DIFFERENCE)
16+
@gl = GLContext.getCurrentGL.getGL2
17+
end
18+
19+
def draw
20+
background(255)
21+
# This provides blendMode(DIFFERENCE) in P2D / P3D
22+
gl.glEnable(GL3::GL_BLEND)
23+
gl.glBlendFunc(GL3::GL_ONE_MINUS_DST_COLOR, GL3::GL_ZERO)
24+
20.times do |i|
25+
sz = 50 + (i % 4) * 50
26+
x = width * noise(i * 0.527 + millis * 0.0003)
27+
y = height * noise(i * 0.729 + millis * 0.0001)
28+
circle(x, y, sz)
29+
end
30+
end
31+
32+
def settings
33+
size 600, 600, P3D
34+
smooth 8
35+
end
36+
end
37+
38+
BlendModeSketch.new

0 commit comments

Comments
 (0)