module TaskJuggler::Painter::Primitives
This module contains utility methods to create the canvas Elements with minimal overhead. The element is added to it's current parent and mandatory arguments are enforced. It also eliminates the need to call 'new' methods of each Element.
Constants
- FillAndStrokeAttrs
- FillAttrs
- StrokeAttrs
- TextAttrs
Public Instance Methods
circle(cx, cy, r, attrs = {})
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 46 def circle(cx, cy, r, attrs = {}) attrs[:cx] = cx attrs[:cy] = cy attrs[:r] = r @elements << (c = Circle.new(attrs)) c end
color(*args)
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 33 def color(*args) Color.new(*args) end
ellipse(cx, cy, rx, ry, attrs = {})
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 54 def ellipse(cx, cy, rx, ry, attrs = {}) attrs[:cx] = cx attrs[:cy] = cy attrs[:rx] = rx attrs[:ry] = ry @elements << (e = Ellipse.new(attrs)) e end
group(attrs = {}, &block)
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 41 def group(attrs = {}, &block) @elements << (g = Group.new(attrs, &block)) g end
line(x1, y1, x2, y2, attrs = {})
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 63 def line(x1, y1, x2, y2, attrs = {}) attrs[:x1] = x1 attrs[:y1] = y1 attrs[:x2] = x2 attrs[:y2] = y2 @elements << (l = Line.new(attrs)) l end
points(arr)
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 37 def points(arr) Points.new(arr) end
polyline(points, attrs = {})
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 72 def polyline(points, attrs = {}) attrs[:points] = points.is_a?(Array) ? Points.new(points) : points @elements << (l = PolyLine.new(attrs)) l end
rect(x, y, width, height, attrs = {})
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 78 def rect(x, y, width, height, attrs = {}) attrs[:x] = x attrs[:y] = y attrs[:width] = width attrs[:height] = height @elements << (r = Rect.new(attrs)) r end
text(x, y, str, attrs = {})
click to toggle source
# File lib/taskjuggler/Painter/Primitives.rb, line 87 def text(x, y, str, attrs = {}) attrs[:x] = x attrs[:y] = y @elements << (t = Text.new(str, attrs)) t end