Module: P5::Block
- Defined in:
- lib/p5rb.rb
Class Attribute Summary collapse
-
.buffer ⇒ Object
writeonly
Sets the attribute buffer.
Class Method Summary collapse
- .background(color) ⇒ Object
- .circle(x, y, r) ⇒ Object
-
.ellipse(*args) ⇒ Object
not tested yet.
- .fill(color, alpha = nil) ⇒ Object
- .line(x1, y1, x2, y2) ⇒ Object
- .map(*args) ⇒ Object
- .noStroke ⇒ Object
- .point(x, y) ⇒ Object
- .raw(_) ⇒ Object
- .rect(x, y, w, h, fill: nil) ⇒ Object
- .stroke(color) ⇒ Object
- .text(text, x, y, fill: nil) ⇒ Object
- .textAlign(*args) ⇒ Object
- .textAscent(text) ⇒ Object
- .textSize(size) ⇒ Object
- .textWidth(text) ⇒ Object
- .translate(x, y) ⇒ Object
Class Attribute Details
.buffer=(value) ⇒ Object (writeonly)
Sets the attribute buffer
11 12 13 |
# File 'lib/p5rb.rb', line 11 def buffer=(value) @buffer = value end |
Class Method Details
.background(color) ⇒ Object
15 16 17 |
# File 'lib/p5rb.rb', line 15 def background color @buffer.push "background(#{color})" end |
.circle(x, y, r) ⇒ Object
30 31 32 |
# File 'lib/p5rb.rb', line 30 def circle x, y, r @buffer.push "circle(#{x}, #{y}, #{r})" end |
.ellipse(*args) ⇒ Object
not tested yet
33 34 35 |
# File 'lib/p5rb.rb', line 33 def ellipse *args # not tested yet @buffer.push "ellipse(#{args.join ?,})" end |
.fill(color, alpha = nil) ⇒ Object
36 37 38 |
# File 'lib/p5rb.rb', line 36 def fill color, alpha = nil @buffer.push "fill(#{color}#{", #{alpha}" if alpha})" end |
.line(x1, y1, x2, y2) ⇒ Object
27 28 29 |
# File 'lib/p5rb.rb', line 27 def line x1, y1, x2, y2 @buffer.push "line(#{x1}, #{y1}, #{x2}, #{y2})" end |
.map(*args) ⇒ Object
64 65 66 |
# File 'lib/p5rb.rb', line 64 def map *args "map(#{args.join ", "})" end |
.noStroke ⇒ Object
18 19 20 |
# File 'lib/p5rb.rb', line 18 def noStroke @buffer.push "noStroke()" end |
.point(x, y) ⇒ Object
44 45 46 |
# File 'lib/p5rb.rb', line 44 def point x, y @buffer.push "point(#{x}, #{y})" end |
.raw(_) ⇒ Object
12 13 14 |
# File 'lib/p5rb.rb', line 12 def raw _ @buffer.push _ end |
.rect(x, y, w, h, fill: nil) ⇒ Object
39 40 41 42 43 |
# File 'lib/p5rb.rb', line 39 def rect x, y, w, h, fill: nil (@buffer.push "push()"; fill fill) if fill @buffer.push "rect(#{x}, #{y}, #{w}, #{h})" @buffer.push "pop()" if fill end |
.stroke(color) ⇒ Object
21 22 23 |
# File 'lib/p5rb.rb', line 21 def stroke color @buffer.push "stroke(#{color})" end |
.text(text, x, y, fill: nil) ⇒ Object
59 60 61 62 63 |
# File 'lib/p5rb.rb', line 59 def text text, x, y, fill: nil (@buffer.push "push()"; fill fill) if fill @buffer.push "text(#{text.inspect}, #{x}, #{y})" @buffer.push "pop()" if fill end |
.textAlign(*args) ⇒ Object
50 51 52 |
# File 'lib/p5rb.rb', line 50 def textAlign *args @buffer.push "textAlign(#{args.join ", "})" end |
.textAscent(text) ⇒ Object
56 57 58 |
# File 'lib/p5rb.rb', line 56 def textAscent text @buffer.push "textAscent(#{text.inspect})" end |
.textSize(size) ⇒ Object
47 48 49 |
# File 'lib/p5rb.rb', line 47 def textSize size @buffer.push "textSize(#{size})" end |
.textWidth(text) ⇒ Object
53 54 55 |
# File 'lib/p5rb.rb', line 53 def textWidth text @buffer.push "textWidth(#{text.inspect})" end |
.translate(x, y) ⇒ Object
24 25 26 |
# File 'lib/p5rb.rb', line 24 def translate x, y @buffer.push "translate(#{x}, #{y})" end |