Class: Ea::Svg::EaEmitter::Element::IconRenderer

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

Overview

Emits the small "folded paper" classifier-type icon at the top-right corner of an element box. EA renders this when the element's style does NOT set HideIcon=1.

The icon is two <path> elements:

1. Outer outline (closed): a 9×11 rectangle with the
 top-right corner "folded" (a 3×4 triangular cut).
2. Folded corner detail (open): the L-shape indicating
 the fold.

Style:

- Outer:    fill=#DCF8F0, stroke=#577AC1
- Corner:   fill=transparent, stroke=#577AC1
- stroke-width=1, stroke-linecap=square, linejoin=bevel

Constant Summary collapse

OUTER_FILL =
"#DCF8F0"
OUTER_STROKE =
"#577AC1"
CORNER_FILL =

transparent black

"##{0.to_s.rjust(6, '0')}"
WIDTH =
9
HEIGHT =
11
FOLD_WIDTH =
3
FOLD_HEIGHT =
4
X_INSET =
13
Y_OFFSET =
3

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bounds:, canvas: nil) ⇒ IconRenderer

Returns a new instance of IconRenderer.



35
36
37
38
# File 'lib/ea/svg/ea_emitter/element/icon_renderer.rb', line 35

def initialize(bounds:, canvas: nil)
  @bounds = bounds
  @canvas = canvas
end

Instance Attribute Details

#boundsObject (readonly)

Returns the value of attribute bounds.



33
34
35
# File 'lib/ea/svg/ea_emitter/element/icon_renderer.rb', line 33

def bounds
  @bounds
end

#canvasObject (readonly)

Returns the value of attribute canvas.



33
34
35
# File 'lib/ea/svg/ea_emitter/element/icon_renderer.rb', line 33

def canvas
  @canvas
end

Class Method Details

.render(bounds:, canvas: nil, family: nil, size: nil) ⇒ Object



40
41
42
# File 'lib/ea/svg/ea_emitter/element/icon_renderer.rb', line 40

def self.render(bounds:, canvas: nil, family: nil, size: nil)
  new(bounds: bounds, canvas: canvas).to_svg
end

Instance Method Details

#to_svgObject

Returns the two <path> elements joined as a single String. Returns "" if bounds is nil.



46
47
48
49
50
# File 'lib/ea/svg/ea_emitter/element/icon_renderer.rb', line 46

def to_svg
  return "" unless bounds

  "#{outer_path}\n#{corner_path}"
end