Class: Ea::Svg::EaEmitter::Element::NoteShapeRenderer

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

Overview

Emits the shape <g> for a Note element: a folded-corner rect plus body text. EA renders every Note element as a dog-eared rectangle (top-right corner folded in) with the note text wrapped inside.

Layout:

┌──────────────────┐
                  
 body text lines   
                  
└──────────────────-

Constant Summary collapse

FOLD_SIZE =
12
TEXT_X_OFFSET =
5
TEXT_Y_OFFSET =
12
LINE_HEIGHT =
12

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bounds, body, fill, stroke, stroke_width, family, size, text_fill) ⇒ NoteShapeRenderer

Returns a new instance of NoteShapeRenderer.



30
31
32
33
34
35
36
37
38
39
# File 'lib/ea/svg/ea_emitter/element/note_shape_renderer.rb', line 30

def initialize(bounds, body, fill, stroke, stroke_width, family, size, text_fill)
  @bounds = bounds
  @body = body.to_s
  @fill = fill
  @stroke = stroke
  @stroke_width = stroke_width
  @family = family
  @size = size
  @text_fill = text_fill
end

Class Method Details

.render(bounds, body:, fill:, stroke:, stroke_width:, family:, size:, text_fill:) ⇒ Object



26
27
28
# File 'lib/ea/svg/ea_emitter/element/note_shape_renderer.rb', line 26

def self.render(bounds, body:, fill:, stroke:, stroke_width:, family:, size:, text_fill:)
  new(bounds, body, fill, stroke, stroke_width, family, size, text_fill).to_svg
end

Instance Method Details

#to_svgObject



41
42
43
# File 'lib/ea/svg/ea_emitter/element/note_shape_renderer.rb', line 41

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