rubysketch 0.3.22 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/{release.yml → release-gem.yml} +21 -21
  3. data/.github/workflows/tag.yml +35 -0
  4. data/.github/workflows/test.yml +8 -9
  5. data/.github/workflows/utils.rb +55 -0
  6. data/ChangeLog.md +7 -164
  7. data/LICENSE +1 -1
  8. data/README.md +1 -1
  9. data/Rakefile +10 -34
  10. data/RubySketch.podspec +4 -3
  11. data/VERSION +1 -1
  12. data/examples/hello.rb +6 -6
  13. data/lib/rubysketch/all.rb +9 -0
  14. data/lib/rubysketch/context.rb +47 -0
  15. data/lib/rubysketch/{module.rb → extension.rb} +3 -3
  16. data/lib/rubysketch/graphics_context.rb +37 -0
  17. data/lib/rubysketch/helper.rb +5 -0
  18. data/lib/rubysketch/sprite.rb +101 -0
  19. data/lib/rubysketch.rb +30 -12
  20. data/rubysketch.gemspec +15 -8
  21. data/src/{RubySketch.h → RubyProcessing.h} +0 -4
  22. data/src/RubyProcessing.mm +25 -0
  23. data/test/helper.rb +3 -10
  24. data/test/test_sprite.rb +23 -0
  25. metadata +119 -35
  26. data/examples/breakout.rb +0 -212
  27. data/examples/camera.rb +0 -14
  28. data/examples/clock.rb +0 -57
  29. data/examples/delay_camera.rb +0 -33
  30. data/examples/glsl.rb +0 -14
  31. data/examples/image.rb +0 -13
  32. data/examples/shapes.rb +0 -121
  33. data/lib/rubysketch/app.rb +0 -13
  34. data/lib/rubysketch/glsl.rb +0 -44
  35. data/lib/rubysketch/processing.rb +0 -3191
  36. data/lib/rubysketch/window.rb +0 -232
  37. data/lib/rubysketch-glsl.rb +0 -12
  38. data/lib/rubysketch-processing.rb +0 -25
  39. data/src/RubySketch.mm +0 -55
  40. data/test/processing/helper.rb +0 -11
  41. data/test/processing/test_graphics.rb +0 -21
  42. data/test/processing/test_shader.rb +0 -47
  43. data/test/processing/test_utility.rb +0 -41
  44. data/test/processing/test_vector.rb +0 -394
data/examples/camera.rb DELETED
@@ -1,14 +0,0 @@
1
- %w[xot rays reflex rubysketch]
2
- .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
- .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
-
5
- require 'rubysketch-processing'
6
-
7
-
8
- cam = Capture.new 300, 300
9
- cam.start
10
-
11
- draw do
12
- background 0
13
- image cam, 0, 0
14
- end
data/examples/clock.rb DELETED
@@ -1,57 +0,0 @@
1
- %w[xot rays reflex rubysketch]
2
- .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
- .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
-
5
- require 'rubysketch-processing'
6
-
7
- COLORS = %w[ #F99292 #FFBC61 #FFC679 #FFF4E0 ]
8
-
9
- def now ()
10
- Time.now.to_f
11
- end
12
-
13
- start = now
14
-
15
- setup do
16
- colorMode RGB, 1
17
- angleMode DEGREES
18
- end
19
-
20
- draw do
21
- background 0
22
-
23
- pushMatrix do
24
- translate width / 2, height / 2
25
-
26
- pushMatrix do
27
- fill COLORS[0]
28
- ellipse 0, 0, 20, 20
29
- rotate (now - start) / 60.0 * 360
30
- stroke COLORS[0]
31
- strokeWeight 5
32
- line 0, 0, 200, 0
33
- fill 1
34
- end
35
-
36
- pushMatrix do
37
- strokeWeight 3
38
- 60.times do
39
- rotate 6
40
- stroke COLORS[1]
41
- line 200, 0, 210, 0
42
- end
43
- end
44
-
45
- pushMatrix do
46
- strokeWeight 5
47
- 12.times do
48
- rotate 30
49
- stroke COLORS[3]
50
- line 190, 0, 210, 0
51
- end
52
- end
53
- end
54
-
55
- textSize 20
56
- text "#{frameRate.to_i} FPS", 10, 10
57
- end
@@ -1,33 +0,0 @@
1
- %w[xot rays reflex rubysketch]
2
- .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
- .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
-
5
- require 'rubysketch-processing'
6
-
7
-
8
- w, h = width, height
9
-
10
- cam = Capture.new w, h, Capture.list.last
11
- cam.start
12
-
13
- images = 60.times.map {
14
- Graphics.new w, h
15
- }
16
-
17
- draw do
18
- if frameCount % 2 == 0
19
- images.unshift images.pop
20
- images.first.tap do |image|
21
- image.beginDraw {
22
- image.image cam, 0, 0
23
- }
24
- end
25
- end
26
-
27
- background 0
28
- segment_h= h / images.size
29
- images.each.with_index do |image, i|
30
- y = i * segment_h
31
- copy image, 0, y, w, segment_h, 0, y, w, segment_h
32
- end
33
- end
data/examples/glsl.rb DELETED
@@ -1,14 +0,0 @@
1
- %w[xot rays reflex rubysketch]
2
- .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
- .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
-
5
- require 'rubysketch-glsl'
6
-
7
- RubySketch::GLSL.run <<END
8
- uniform vec2 resolution;
9
- uniform float time;
10
- void main() {
11
- vec2 pos = gl_FragCoord.xy / resolution;
12
- gl_FragColor = vec4(pos * abs(sin(time)), 0, 1);
13
- }
14
- END
data/examples/image.rb DELETED
@@ -1,13 +0,0 @@
1
- %w[xot rays reflex rubysketch]
2
- .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
- .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
-
5
- require 'rubysketch-processing'
6
-
7
-
8
- icon = loadImage 'https://xord.org/rubysketch/images/rubysketch128.png'
9
-
10
- draw do
11
- background 0, 10
12
- image icon, mouseX, mouseY, icon.width / 10, icon.height / 10
13
- end
data/examples/shapes.rb DELETED
@@ -1,121 +0,0 @@
1
- %w[xot rays reflex rubysketch]
2
- .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
- .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
-
5
- require 'rubysketch-processing'
6
-
7
-
8
- setup do
9
- colorMode RGB, 1
10
- angleMode DEGREES
11
- end
12
-
13
- draw do
14
- background 0
15
-
16
- fill 1
17
- stroke 1, 0.5, 0.2
18
-
19
- translate 10, 10
20
-
21
- push
22
-
23
- text 'point', 0, 0
24
- point 0, 30
25
-
26
- translate 0, 100
27
-
28
- text 'point with strokeWeight', 0, 0
29
- strokeWeight 10
30
- point 0, 30
31
- strokeWeight 0
32
-
33
- translate 0, 100
34
-
35
- text 'line', 0, 0
36
- line 0, 30, 100, 50
37
-
38
- translate 0, 100
39
-
40
- text 'line with strokeWeight (very slow)', 0, 0
41
- strokeWeight 10
42
- line 0, 30, 100, 50
43
- strokeWeight 1
44
-
45
- translate 0, 100
46
-
47
- text 'rect with rectMode(CORNER)', 0, 0
48
- rectMode CORNER
49
- rect 20, 30, 100, 50
50
-
51
- translate 0, 100
52
-
53
- text 'rect with rectMode(CORNERS)', 0, 0
54
- rectMode CORNERS
55
- rect 20, 30, 120, 80
56
-
57
- translate 0, 100
58
-
59
- text 'rect with rectMode(CENTER)', 0, 0
60
- rectMode CENTER
61
- rect 70, 55, 100, 50
62
-
63
- translate 0, 100
64
-
65
- text 'rect with rectMode(RADIUS)', 0, 0
66
- rectMode RADIUS
67
- rect 70, 55, 50, 25
68
-
69
- pop
70
- translate 200, 0
71
- push
72
-
73
- text 'circle', 0, 0
74
- circle 70, 55, 25
75
-
76
- translate 0, 100
77
-
78
- text 'arc', 0, 0
79
- arc 70, 55, 100, 50, 45, 270
80
-
81
- translate 0, 100
82
-
83
- text 'square', 0, 0
84
- square 20, 30, 50
85
-
86
- translate 0, 100
87
-
88
- text 'triangle', 0, 0
89
- triangle 70, 30, 120, 80, 20, 80
90
-
91
- translate 0, 100
92
-
93
- text 'quad', 0, 0
94
- quad 20, 30, 120, 30, 150, 80, 50, 80
95
-
96
- translate 0, 100
97
-
98
- text 'ellipse with ellipseMode(CORNER)', 0, 0
99
- ellipseMode CORNER
100
- ellipse 20, 30, 100, 50
101
-
102
- translate 0, 100
103
-
104
- text 'ellipse with ellipseMode(CORNERS)', 0, 0
105
- ellipseMode CORNERS
106
- ellipse 20, 30, 120, 80
107
-
108
- translate 0, 100
109
-
110
- text 'ellipse with ellipseMode(CENTER)', 0, 0
111
- ellipseMode CENTER
112
- ellipse 70, 55, 100, 50
113
-
114
- translate 0, 100
115
-
116
- text 'ellipse with ellipseMode(RADIUS)', 0, 0
117
- ellipseMode RADIUS
118
- ellipse 70, 55, 50, 25
119
-
120
- pop
121
- end
@@ -1,13 +0,0 @@
1
- module RubySketch
2
-
3
-
4
- class App < Reflex::Application
5
-
6
- def on_motion(e)
7
- RubySketch.instance_variable_get(:@window)&.on_motion e
8
- end
9
-
10
- end# App
11
-
12
-
13
- end# RubySketch
@@ -1,44 +0,0 @@
1
- module RubySketch
2
-
3
-
4
- # OpenGL Shader Language
5
- #
6
- module GLSL
7
-
8
-
9
- # @private
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
26
- p.fill 1
27
- p.rect 0, 0, w, h
28
- end
29
- end
30
-
31
- private
32
-
33
- # @private
34
- def now__()
35
- Time.now.to_f
36
- end
37
-
38
- end# Context
39
-
40
-
41
- end# GLSL
42
-
43
-
44
- end# RubySketch