Module: Dieses::Application::Pen::Draw::Elements

Included in:
Dieses::Application::Pen::Draw
Defined in:
lib/dieses/application/pen.rb

Instance Method Summary collapse

Instance Method Details

#cline(*tags, angle:, style: Undefined) ⇒ Object



74
75
76
# File 'lib/dieses/application/pen.rb', line 74

def cline(*tags, angle:, style: Undefined)
  add perfect.intersect(Geometry::Equation.slant_from_direction(point: pos, angle: -angle)), tags, style
end

#hline(*tags, length: Undefined, style: Undefined) ⇒ Object



64
65
66
67
# File 'lib/dieses/application/pen.rb', line 64

def hline(*tags, length: Undefined, style: Undefined)
  length = Undefined.equal?(length) ? perfect.width : ruler.measure(length)
  add Geometry::Line.new(pos, pos.translate(x: length)), tags, style
end

#rect(*tags, width:, height:, style: Undefined) ⇒ Object



78
79
80
81
82
# File 'lib/dieses/application/pen.rb', line 78

def rect(*tags, width:, height:, style: Undefined)
  width, height = ruler.measure(width), ruler.measure(height)
  style = { fill: 'none' }.merge Undefined.default(style, EMPTY_HASH).to_h
  add Geometry::Rect.new(width, height, position: pos), tags, style
end

#square(*tags, width:, style: Undefined) ⇒ Object



84
85
86
# File 'lib/dieses/application/pen.rb', line 84

def square(*tags, width:, style: Undefined)
  rect(tags, width: width, height: width, style: style)
end

#vline(*tags, length: Undefined, style: Undefined) ⇒ Object



69
70
71
72
# File 'lib/dieses/application/pen.rb', line 69

def vline(*tags, length: Undefined, style: Undefined)
  length = Undefined.equal?(length) ? perfect.height : ruler.measure(length)
  add Geometry::Line.new(pos, pos.translate(y: length)), tags, style
end