rubysketch 0.3.20 → 0.3.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +2 -2
- data/ChangeLog.md +24 -0
- data/Gemfile +1 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/examples/glsl.rb +5 -8
- data/lib/rubysketch/glsl.rb +29 -16
- data/lib/rubysketch/processing.rb +1085 -679
- data/lib/rubysketch/window.rb +91 -64
- data/lib/rubysketch-glsl.rb +12 -0
- data/rubysketch.gemspec +3 -1
- data/test/processing/helper.rb +11 -0
- data/test/processing/test_graphics.rb +21 -0
- data/test/processing/test_shader.rb +47 -0
- data/test/processing/test_utility.rb +20 -13
- data/test/processing/test_vector.rb +1 -1
- metadata +26 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37319632030509f708c8ee98cbb6e4d8512b50ad7475cae37d595e3649a81c26
|
4
|
+
data.tar.gz: c61938eefd83489171e8eff04721dfd08edcbae0ecb8472b34c58d1c09afc92a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e37b6b72fd7d3960434d47b302aec206332e85476a7e2cde3d4f56fd8b8946de685c27fc39d06094ddb0203141ba8282a2b521281218dd25970fceb18e80a83f
|
7
|
+
data.tar.gz: 9c65761f2df604c2c79b30ccc5c6b23403d7aae5f2ea6858b62979b825d66ef1d54a9106ad37b4dfd5902697a91bd47c0c034e6fd21c93fe1593a58642fb20eb
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
# RubySketch ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [0.3.22] - 2022-11-14
|
5
|
+
|
6
|
+
RubySketch::Processing
|
7
|
+
- add Shader class
|
8
|
+
- add shader(), resetShader(), createShader(), loadShader(), and filter()
|
9
|
+
- update the pixel density of context if the screen pixel density is changed
|
10
|
+
- setUniform() can also take array of numbers, vector, and texture image.
|
11
|
+
- pushStyle() manages states of textAlign, tint, and filter
|
12
|
+
- push/pushMatrix/pushStyle call pop() on ensure
|
13
|
+
|
14
|
+
RubySketch::GLSL
|
15
|
+
- displays with pixel density 1.0
|
16
|
+
|
17
|
+
|
18
|
+
## [0.3.21] - 2022-09-05
|
19
|
+
|
20
|
+
- add rubysketch-glsl.rb
|
21
|
+
- add blend(), createImage(), setTitle(), tint() and noTint()
|
22
|
+
- add save() that saves screen image to file
|
23
|
+
- circle() function is affected by ellipseMode()
|
24
|
+
- point() draws by line(x, y, x, y)
|
25
|
+
- change initial values for strokeCap and strokeJoin to ROUND and MITER
|
26
|
+
|
27
|
+
|
4
28
|
## [0.3.20] - 2022-07-24
|
5
29
|
|
6
30
|
- add mouseClicked()
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.22
|
data/examples/glsl.rb
CHANGED
@@ -2,16 +2,13 @@
|
|
2
2
|
.map {|s| File.expand_path "../../#{s}/lib", __dir__}
|
3
3
|
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
4
4
|
|
5
|
-
require 'rubysketch'
|
5
|
+
require 'rubysketch-glsl'
|
6
6
|
|
7
|
-
|
8
|
-
RubySketch::GLSL.start <<END
|
9
|
-
varying vec4 v_TexCoord;
|
7
|
+
RubySketch::GLSL.run <<END
|
10
8
|
uniform vec2 resolution;
|
11
9
|
uniform float time;
|
12
|
-
void main
|
13
|
-
|
14
|
-
|
15
|
-
gl_FragColor = vec4(pos, float(mod(time, 1.0)), 1);
|
10
|
+
void main() {
|
11
|
+
vec2 pos = gl_FragCoord.xy / resolution;
|
12
|
+
gl_FragColor = vec4(pos * abs(sin(time)), 0, 1);
|
16
13
|
}
|
17
14
|
END
|
data/lib/rubysketch/glsl.rb
CHANGED
@@ -1,29 +1,42 @@
|
|
1
1
|
module RubySketch
|
2
2
|
|
3
3
|
|
4
|
-
#
|
5
|
-
|
4
|
+
# OpenGL Shader Language
|
5
|
+
#
|
6
|
+
module GLSL
|
6
7
|
|
7
|
-
def initialize(glsl)
|
8
|
-
@shader = Reflex::Shader.new glsl
|
9
|
-
end
|
10
8
|
|
11
9
|
# @private
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
window
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
class Context
|
11
|
+
|
12
|
+
# @private
|
13
|
+
def initialize(window)
|
14
|
+
@window = window
|
15
|
+
@window.__send__ :resize_canvas, window.width, window.height, 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def run(shader_source)
|
19
|
+
shader = Rays::Shader.new(
|
20
|
+
shader_source, ignore_no_uniform_location_error: true)
|
21
|
+
start = now__
|
22
|
+
@window.draw = proc do |e|
|
23
|
+
i, p = @window.canvas_image, @window.canvas_painter
|
24
|
+
w, h = i.width, i.height
|
25
|
+
p.shader shader, resolution: [w, h], time: now__ - start
|
22
26
|
p.fill 1
|
23
27
|
p.rect 0, 0, w, h
|
24
28
|
end
|
25
29
|
end
|
26
|
-
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# @private
|
34
|
+
def now__()
|
35
|
+
Time.now.to_f
|
36
|
+
end
|
37
|
+
|
38
|
+
end# Context
|
39
|
+
|
27
40
|
|
28
41
|
end# GLSL
|
29
42
|
|