sandoz 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/lib/sandoz.rb +1 -142
- data/lib/sandoz/sandoz.rb +8 -0
- data/lib/sandoz/sandoz/sandoz.rb +140 -0
- data/lib/sandoz/sandoz/version.rb +3 -0
- data/lib/sandoz/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 252aec0848aebfa11501b3598a38bed172caf85a
|
4
|
+
data.tar.gz: 47e143777d9e0808b88876c4166ed3ad42bb98b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d209c100574284c5af4267f68180eceb4b82617259a2d04033e20d29cb7325803f664f232693283d21a328c9747d0244f460449b12a87da09711cf17236f4adb
|
7
|
+
data.tar.gz: e3936f80fda94c54a5a071b40c05c2157701b08544605f5537258b099145e9ad2943f2e95b15688f5056dea92c848a011a91fd3ee63275ce4f06da1683243b51
|
data/lib/sandoz.rb
CHANGED
@@ -1,142 +1 @@
|
|
1
|
-
require 'sandoz/
|
2
|
-
|
3
|
-
module Sandoz
|
4
|
-
# https://github.com/processing/p5.js/wiki/p5.js-overview#instantiation--namespace
|
5
|
-
# TODO Add html element argument
|
6
|
-
def defsketch(id, &block)
|
7
|
-
sketch = Proc.new do |p|
|
8
|
-
init(p)
|
9
|
-
block.call
|
10
|
-
end
|
11
|
-
@p5 = `new p5(#{sketch}, #{id})`
|
12
|
-
end
|
13
|
-
|
14
|
-
def view_p
|
15
|
-
`return #{@p5}`
|
16
|
-
end
|
17
|
-
|
18
|
-
def init(p)
|
19
|
-
@@p = p
|
20
|
-
end
|
21
|
-
|
22
|
-
def size(w, h)
|
23
|
-
`#{@@p}.createCanvas(#{w}, #{h})`
|
24
|
-
end
|
25
|
-
|
26
|
-
def background(r, g=nil, b=nil)
|
27
|
-
if g == nil && b == nil
|
28
|
-
`#{@@p}.background(#{r})`
|
29
|
-
else
|
30
|
-
`#{@@p}.background(#{r}, #{g}, #{b})`
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def fill(r, g=nil, b=nil, a=nil)
|
35
|
-
if g==nil && b ==nil
|
36
|
-
`#{@@p}.fill(#{r})`
|
37
|
-
elsif a == nil
|
38
|
-
`#{@@p}.fill(#{r}, #{g}, #{b})`
|
39
|
-
else
|
40
|
-
`#{@@p}.fill(#{r}, #{g}, #{b}, #{a})`
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def rect(x, y, w, h)
|
45
|
-
`#{@@p}.rect(#{x}, #{y}, #{w}, #{h})`
|
46
|
-
end
|
47
|
-
|
48
|
-
def ellipse(x, y, w, h)
|
49
|
-
`#{@@p}.ellipse(#{x}, #{y}, #{w}, #{h})`
|
50
|
-
end
|
51
|
-
|
52
|
-
def width
|
53
|
-
`#{@@p}.width`
|
54
|
-
end
|
55
|
-
|
56
|
-
def height
|
57
|
-
`#{@@p}.height`
|
58
|
-
end
|
59
|
-
|
60
|
-
def line(x1, y1, x2, y2)
|
61
|
-
`#{@@p}.line(#{x1}, #{y1}, #{x2}, #{y2})`
|
62
|
-
end
|
63
|
-
|
64
|
-
def point(x, y)
|
65
|
-
`#{@@p}.point(#{x}, #{y})`
|
66
|
-
end
|
67
|
-
|
68
|
-
def stroke(r, g=nil, b=nil, a=nil)
|
69
|
-
if g==nil && b ==nil
|
70
|
-
`#{@@p}.stroke(#{r})`
|
71
|
-
elsif a == nil
|
72
|
-
`#{@@p}.stroke(#{r}, #{g}, #{b})`
|
73
|
-
else
|
74
|
-
`#{@@p}.stroke(#{r}, #{g}, #{b}, #{a})`
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def no_stroke
|
79
|
-
`#{@@p}.noStroke()`
|
80
|
-
end
|
81
|
-
|
82
|
-
def stroke_weight(weight)
|
83
|
-
`#{@@p}.strokeWeight(#{weight})`
|
84
|
-
end
|
85
|
-
|
86
|
-
def setup(&block)
|
87
|
-
`#{@@p}.setup = #{block}`
|
88
|
-
end
|
89
|
-
|
90
|
-
def draw(&block)
|
91
|
-
`#{@@p}.draw = #{block}`
|
92
|
-
end
|
93
|
-
|
94
|
-
def dist(x1, y1, x2, y2)
|
95
|
-
`return #{@@p}.dist(x1, y1, x2, y2)`
|
96
|
-
end
|
97
|
-
|
98
|
-
def random(min, max=nil)
|
99
|
-
if max
|
100
|
-
`return #{@@p}.random(#{min}, #{max})`
|
101
|
-
else
|
102
|
-
`return #{@@p}.random(#{min})`
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def color(r, g=nil, b=nil, a=nil)
|
107
|
-
if g==nil && b ==nil
|
108
|
-
`return #{@@p}.color(#{r})`
|
109
|
-
elsif a == nil
|
110
|
-
`return #{@@p}.color(#{r}, #{g}, #{b})`
|
111
|
-
else
|
112
|
-
`return #{@@p}.color(#{r}, #{g}, #{b}, #{a})`
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def map(value, start1, stop1, start2, stop2)
|
117
|
-
`return #{@@p}.map(#{value}, #{start1}, #{stop1}, #{start2}, #{stop2})`
|
118
|
-
end
|
119
|
-
|
120
|
-
def millis
|
121
|
-
`return #{@@p}.millis();`
|
122
|
-
end
|
123
|
-
|
124
|
-
def no_fill
|
125
|
-
`#{@@p}.noFill()`
|
126
|
-
end
|
127
|
-
|
128
|
-
def noise(x, y=nil, z=nil)
|
129
|
-
if y == nil && z == nil
|
130
|
-
`return #{@@p}.noise(#{x})`
|
131
|
-
elsif z == nil
|
132
|
-
`return #{@@p}.noise(#{x}, #{y})`
|
133
|
-
else
|
134
|
-
`return #{@@p}.noise(#{x}, #{y}, #{z})`
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def text(text, x, y)
|
139
|
-
`#{@@p}.text(#{text}, #{x}, #{y})`
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
1
|
+
require 'sandoz/sandoz'
|
@@ -0,0 +1,140 @@
|
|
1
|
+
module Sandoz
|
2
|
+
# https://github.com/processing/p5.js/wiki/p5.js-overview#instantiation--namespace
|
3
|
+
# TODO Add html element argument
|
4
|
+
def defsketch(id, &block)
|
5
|
+
sketch = Proc.new do |p|
|
6
|
+
init(p)
|
7
|
+
block.call
|
8
|
+
end
|
9
|
+
@p5 = `new p5(#{sketch}, #{id})`
|
10
|
+
end
|
11
|
+
|
12
|
+
def view_p
|
13
|
+
`return #{@p5}`
|
14
|
+
end
|
15
|
+
|
16
|
+
def init(p)
|
17
|
+
@@p = p
|
18
|
+
end
|
19
|
+
|
20
|
+
def size(w, h)
|
21
|
+
`#{@@p}.createCanvas(#{w}, #{h})`
|
22
|
+
end
|
23
|
+
|
24
|
+
def background(r, g=nil, b=nil)
|
25
|
+
if g == nil && b == nil
|
26
|
+
`#{@@p}.background(#{r})`
|
27
|
+
else
|
28
|
+
`#{@@p}.background(#{r}, #{g}, #{b})`
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def fill(r, g=nil, b=nil, a=nil)
|
33
|
+
if g==nil && b ==nil
|
34
|
+
`#{@@p}.fill(#{r})`
|
35
|
+
elsif a == nil
|
36
|
+
`#{@@p}.fill(#{r}, #{g}, #{b})`
|
37
|
+
else
|
38
|
+
`#{@@p}.fill(#{r}, #{g}, #{b}, #{a})`
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def rect(x, y, w, h)
|
43
|
+
`#{@@p}.rect(#{x}, #{y}, #{w}, #{h})`
|
44
|
+
end
|
45
|
+
|
46
|
+
def ellipse(x, y, w, h)
|
47
|
+
`#{@@p}.ellipse(#{x}, #{y}, #{w}, #{h})`
|
48
|
+
end
|
49
|
+
|
50
|
+
def width
|
51
|
+
`#{@@p}.width`
|
52
|
+
end
|
53
|
+
|
54
|
+
def height
|
55
|
+
`#{@@p}.height`
|
56
|
+
end
|
57
|
+
|
58
|
+
def line(x1, y1, x2, y2)
|
59
|
+
`#{@@p}.line(#{x1}, #{y1}, #{x2}, #{y2})`
|
60
|
+
end
|
61
|
+
|
62
|
+
def point(x, y)
|
63
|
+
`#{@@p}.point(#{x}, #{y})`
|
64
|
+
end
|
65
|
+
|
66
|
+
def stroke(r, g=nil, b=nil, a=nil)
|
67
|
+
if g==nil && b ==nil
|
68
|
+
`#{@@p}.stroke(#{r})`
|
69
|
+
elsif a == nil
|
70
|
+
`#{@@p}.stroke(#{r}, #{g}, #{b})`
|
71
|
+
else
|
72
|
+
`#{@@p}.stroke(#{r}, #{g}, #{b}, #{a})`
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def no_stroke
|
77
|
+
`#{@@p}.noStroke()`
|
78
|
+
end
|
79
|
+
|
80
|
+
def stroke_weight(weight)
|
81
|
+
`#{@@p}.strokeWeight(#{weight})`
|
82
|
+
end
|
83
|
+
|
84
|
+
def setup(&block)
|
85
|
+
`#{@@p}.setup = #{block}`
|
86
|
+
end
|
87
|
+
|
88
|
+
def draw(&block)
|
89
|
+
`#{@@p}.draw = #{block}`
|
90
|
+
end
|
91
|
+
|
92
|
+
def dist(x1, y1, x2, y2)
|
93
|
+
`return #{@@p}.dist(x1, y1, x2, y2)`
|
94
|
+
end
|
95
|
+
|
96
|
+
def random(min, max=nil)
|
97
|
+
if max
|
98
|
+
`return #{@@p}.random(#{min}, #{max})`
|
99
|
+
else
|
100
|
+
`return #{@@p}.random(#{min})`
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def color(r, g=nil, b=nil, a=nil)
|
105
|
+
if g==nil && b ==nil
|
106
|
+
`return #{@@p}.color(#{r})`
|
107
|
+
elsif a == nil
|
108
|
+
`return #{@@p}.color(#{r}, #{g}, #{b})`
|
109
|
+
else
|
110
|
+
`return #{@@p}.color(#{r}, #{g}, #{b}, #{a})`
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def map(value, start1, stop1, start2, stop2)
|
115
|
+
`return #{@@p}.map(#{value}, #{start1}, #{stop1}, #{start2}, #{stop2})`
|
116
|
+
end
|
117
|
+
|
118
|
+
def millis
|
119
|
+
`return #{@@p}.millis();`
|
120
|
+
end
|
121
|
+
|
122
|
+
def no_fill
|
123
|
+
`#{@@p}.noFill()`
|
124
|
+
end
|
125
|
+
|
126
|
+
def noise(x, y=nil, z=nil)
|
127
|
+
if y == nil && z == nil
|
128
|
+
`return #{@@p}.noise(#{x})`
|
129
|
+
elsif z == nil
|
130
|
+
`return #{@@p}.noise(#{x}, #{y})`
|
131
|
+
else
|
132
|
+
`return #{@@p}.noise(#{x}, #{y}, #{z})`
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def text(text, x, y)
|
137
|
+
`#{@@p}.text(#{text}, #{x}, #{y})`
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
data/lib/sandoz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandoz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harley Swick
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,6 +70,9 @@ files:
|
|
70
70
|
- bin/console
|
71
71
|
- bin/setup
|
72
72
|
- lib/sandoz.rb
|
73
|
+
- lib/sandoz/sandoz.rb
|
74
|
+
- lib/sandoz/sandoz/sandoz.rb
|
75
|
+
- lib/sandoz/sandoz/version.rb
|
73
76
|
- lib/sandoz/version.rb
|
74
77
|
- sandoz.gemspec
|
75
78
|
homepage: https://github.com/hswick/sandoz
|