Module: Sandoz
- Defined in:
- lib/cli.rb,
lib/sandoz/sandoz.rb,
lib/sandoz/version.rb
Defined Under Namespace
Classes: Cli
Constant Summary collapse
- VERSION =
"0.1.52"
Instance Method Summary collapse
- #background(r, g = nil, b = nil) ⇒ Object
- #color(r, g = nil, b = nil, a = nil) ⇒ Object
-
#defsketch(id, &block) ⇒ Object
github.com/processing/p5.js/wiki/p5.js-overview#instantiation–namespace TODO Add html element argument.
- #dist(x1, y1, x2, y2) ⇒ Object
- #draw(&block) ⇒ Object
- #ellipse(x, y, w, h) ⇒ Object
- #fill(r, g = nil, b = nil, a = nil) ⇒ Object
- #height ⇒ Object
- #init(p) ⇒ Object
- #line(x1, y1, x2, y2) ⇒ Object
- #map(value, start1, stop1, start2, stop2) ⇒ Object
- #millis ⇒ Object
- #no_fill ⇒ Object
- #no_stroke ⇒ Object
- #noise(x, y = nil, z = nil) ⇒ Object
- #point(x, y) ⇒ Object
- #random(min, max = nil) ⇒ Object
- #rect(x, y, w, h) ⇒ Object
- #setup(&block) ⇒ Object
- #size(w, h) ⇒ Object
- #stroke(r, g = nil, b = nil, a = nil) ⇒ Object
- #stroke_weight(weight) ⇒ Object
- #text(text, x, y) ⇒ Object
- #view_p ⇒ Object
- #width ⇒ Object
Instance Method Details
#background(r, g = nil, b = nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/sandoz/sandoz.rb', line 24 def background(r, g=nil, b=nil) if g == nil && b == nil `#{@@p}.background(#{r})` else `#{@@p}.background(#{r}, #{g}, #{b})` end end |
#color(r, g = nil, b = nil, a = nil) ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/sandoz/sandoz.rb', line 104 def color(r, g=nil, b=nil, a=nil) if g==nil && b ==nil `return #{@@p}.color(#{r})` elsif a == nil `return #{@@p}.color(#{r}, #{g}, #{b})` else `return #{@@p}.color(#{r}, #{g}, #{b}, #{a})` end end |
#defsketch(id, &block) ⇒ Object
github.com/processing/p5.js/wiki/p5.js-overview#instantiation–namespace TODO Add html element argument
4 5 6 7 8 9 10 |
# File 'lib/sandoz/sandoz.rb', line 4 def defsketch(id, &block) sketch = Proc.new do |p| init(p) block.call end @p5 = `new p5(#{sketch}, #{id})` end |
#dist(x1, y1, x2, y2) ⇒ Object
92 93 94 |
# File 'lib/sandoz/sandoz.rb', line 92 def dist(x1, y1, x2, y2) `return #{@@p}.dist(x1, y1, x2, y2)` end |
#draw(&block) ⇒ Object
88 89 90 |
# File 'lib/sandoz/sandoz.rb', line 88 def draw(&block) `#{@@p}.draw = #{block}` end |
#ellipse(x, y, w, h) ⇒ Object
46 47 48 |
# File 'lib/sandoz/sandoz.rb', line 46 def ellipse(x, y, w, h) `#{@@p}.ellipse(#{x}, #{y}, #{w}, #{h})` end |
#fill(r, g = nil, b = nil, a = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/sandoz/sandoz.rb', line 32 def fill(r, g=nil, b=nil, a=nil) if g==nil && b ==nil `#{@@p}.fill(#{r})` elsif a == nil `#{@@p}.fill(#{r}, #{g}, #{b})` else `#{@@p}.fill(#{r}, #{g}, #{b}, #{a})` end end |
#height ⇒ Object
54 55 56 |
# File 'lib/sandoz/sandoz.rb', line 54 def height `#{@@p}.height` end |
#init(p) ⇒ Object
16 17 18 |
# File 'lib/sandoz/sandoz.rb', line 16 def init(p) @@p = p end |
#line(x1, y1, x2, y2) ⇒ Object
58 59 60 |
# File 'lib/sandoz/sandoz.rb', line 58 def line(x1, y1, x2, y2) `#{@@p}.line(#{x1}, #{y1}, #{x2}, #{y2})` end |
#map(value, start1, stop1, start2, stop2) ⇒ Object
114 115 116 |
# File 'lib/sandoz/sandoz.rb', line 114 def map(value, start1, stop1, start2, stop2) `return #{@@p}.map(#{value}, #{start1}, #{stop1}, #{start2}, #{stop2})` end |
#millis ⇒ Object
118 119 120 |
# File 'lib/sandoz/sandoz.rb', line 118 def millis `return #{@@p}.millis();` end |
#no_fill ⇒ Object
122 123 124 |
# File 'lib/sandoz/sandoz.rb', line 122 def no_fill `#{@@p}.noFill()` end |
#no_stroke ⇒ Object
76 77 78 |
# File 'lib/sandoz/sandoz.rb', line 76 def no_stroke `#{@@p}.noStroke()` end |
#noise(x, y = nil, z = nil) ⇒ Object
126 127 128 129 130 131 132 133 134 |
# File 'lib/sandoz/sandoz.rb', line 126 def noise(x, y=nil, z=nil) if y == nil && z == nil `return #{@@p}.noise(#{x})` elsif z == nil `return #{@@p}.noise(#{x}, #{y})` else `return #{@@p}.noise(#{x}, #{y}, #{z})` end end |
#point(x, y) ⇒ Object
62 63 64 |
# File 'lib/sandoz/sandoz.rb', line 62 def point(x, y) `#{@@p}.point(#{x}, #{y})` end |
#random(min, max = nil) ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/sandoz/sandoz.rb', line 96 def random(min, max=nil) if max `return #{@@p}.random(#{min}, #{max})` else `return #{@@p}.random(#{min})` end end |
#rect(x, y, w, h) ⇒ Object
42 43 44 |
# File 'lib/sandoz/sandoz.rb', line 42 def rect(x, y, w, h) `#{@@p}.rect(#{x}, #{y}, #{w}, #{h})` end |
#setup(&block) ⇒ Object
84 85 86 |
# File 'lib/sandoz/sandoz.rb', line 84 def setup(&block) `#{@@p}.setup = #{block}` end |
#size(w, h) ⇒ Object
20 21 22 |
# File 'lib/sandoz/sandoz.rb', line 20 def size(w, h) `#{@@p}.createCanvas(#{w}, #{h})` end |
#stroke(r, g = nil, b = nil, a = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/sandoz/sandoz.rb', line 66 def stroke(r, g=nil, b=nil, a=nil) if g==nil && b ==nil `#{@@p}.stroke(#{r})` elsif a == nil `#{@@p}.stroke(#{r}, #{g}, #{b})` else `#{@@p}.stroke(#{r}, #{g}, #{b}, #{a})` end end |
#stroke_weight(weight) ⇒ Object
80 81 82 |
# File 'lib/sandoz/sandoz.rb', line 80 def stroke_weight(weight) `#{@@p}.strokeWeight(#{weight})` end |
#text(text, x, y) ⇒ Object
136 137 138 |
# File 'lib/sandoz/sandoz.rb', line 136 def text(text, x, y) `#{@@p}.text(#{text}, #{x}, #{y})` end |
#view_p ⇒ Object
12 13 14 |
# File 'lib/sandoz/sandoz.rb', line 12 def view_p `return #{@p5}` end |
#width ⇒ Object
50 51 52 |
# File 'lib/sandoz/sandoz.rb', line 50 def width `#{@@p}.width` end |