rubysketch 0.3.21 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,38 +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, shader_source)
14
- shader = Rays::Shader.new shader_source
15
- start = now__
16
- window.draw = proc do |e|
17
- i, p = window.canvas_image, window.canvas_painter
18
- w, h = i.width, i.height
19
- p.shader shader, resolution: [w, h], time: now__ - start
20
- p.fill 1
21
- p.rect 0, 0, w, h
22
- end
23
- end
24
-
25
- private
26
-
27
- # @private
28
- def now__()
29
- Time.now.to_f
30
- end
31
-
32
- end# Context
33
-
34
-
35
- end# GLSL
36
-
37
-
38
- end# RubySketch