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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d0836f855d3ae54ed3cdeaec0d4d479da386cb0a09684fce54d5b2b17cc4c72
4
- data.tar.gz: 72af8263d9531136860ce15145b59011c838743f64659362bd66e4ae6c717d1c
3
+ metadata.gz: 37319632030509f708c8ee98cbb6e4d8512b50ad7475cae37d595e3649a81c26
4
+ data.tar.gz: c61938eefd83489171e8eff04721dfd08edcbae0ecb8472b34c58d1c09afc92a
5
5
  SHA512:
6
- metadata.gz: 5dc6de1cba1571960c9cd9a621b568ee7257b11c537ac74a827cdf3d95fadbb33a0c25258177b0fec299e766c7f78c0e82a308319a38fdd004fe340a7be4ebe4
7
- data.tar.gz: 9cac5e78ddb2a9c7bf4e5e53c294321155bc4276cefed59ba115e44e1370fe9ca15c2ebd404615bceb72305f022a329be915d1d197df587770fe42376df87f88
6
+ metadata.gz: e37b6b72fd7d3960434d47b302aec206332e85476a7e2cde3d4f56fd8b8946de685c27fc39d06094ddb0203141ba8282a2b521281218dd25970fceb18e80a83f
7
+ data.tar.gz: 9c65761f2df604c2c79b30ccc5c6b23403d7aae5f2ea6858b62979b825d66ef1d54a9106ad37b4dfd5902697a91bd47c0c034e6fd21c93fe1593a58642fb20eb
@@ -12,10 +12,10 @@ jobs:
12
12
  - name: checkout
13
13
  uses: actions/checkout@v2
14
14
 
15
- - name: ruby 2.7
15
+ - name: ruby 3.0
16
16
  uses: actions/setup-ruby@v1
17
17
  with:
18
- ruby-version: 2.7.x
18
+ ruby-version: 3.0.x
19
19
 
20
20
  - name: install gems
21
21
  run: |
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
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'yard'
4
- gem 'reflexion'
3
+ gemspec
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ test_ruby_extension
22
22
  generate_documents
23
23
  build_ruby_gem
24
24
 
25
- task :default => :test
25
+ task :default
26
26
 
27
27
 
28
28
  namespace :version do
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.20
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
- vec2 pos = v_TexCoord.xy / resolution;
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
@@ -1,29 +1,42 @@
1
1
  module RubySketch
2
2
 
3
3
 
4
- # @private
5
- class GLSL
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
- def on_start__(window)
13
- start = Time.now.to_f
14
-
15
- window.draw = proc do |e, painter|
16
- painter.paint do |p|
17
- c = window.canvas
18
- w = c.width
19
- h = c.height
20
- t = Time.now.to_f - start
21
- p.shader @shader, resolution: [w, h], time: t if @shader
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
- end
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