Class: Ea::Svg::EaEmitter::Element::HandDrawShapeRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/svg/ea_emitter/element/hand_draw_shape_renderer.rb

Overview

Emits a hand-drawn style shape <path> for elements on diagrams that have HandDraw=1 in their StyleEx. EA renders each element as a closed <path> with cubic beziers per side (slight wave) instead of a clean <rect>. Used by Domain Model diagrams.

Constant Summary collapse

WAVE_AMPLITUDE =
2
WAVE_LENGTH =
70

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bounds, fill, stroke, stroke_width) ⇒ HandDrawShapeRenderer

Returns a new instance of HandDrawShapeRenderer.



20
21
22
23
24
25
# File 'lib/ea/svg/ea_emitter/element/hand_draw_shape_renderer.rb', line 20

def initialize(bounds, fill, stroke, stroke_width)
  @bounds = bounds
  @fill = fill
  @stroke = stroke
  @stroke_width = stroke_width
end

Class Method Details

.render(bounds, fill:, stroke:, stroke_width:) ⇒ Object



16
17
18
# File 'lib/ea/svg/ea_emitter/element/hand_draw_shape_renderer.rb', line 16

def self.render(bounds, fill:, stroke:, stroke_width:)
  new(bounds, fill, stroke, stroke_width).to_svg
end

Instance Method Details

#to_svgObject



27
28
29
# File 'lib/ea/svg/ea_emitter/element/hand_draw_shape_renderer.rb', line 27

def to_svg
  %(<g style="#{group_style}">\n  #{shape_path}\n</g>)
end