Class: Shellfie::RenderGeometry

Inherits:
Object
  • Object
show all
Defined in:
lib/shellfie/render_geometry.rb

Instance Method Summary collapse

Constructor Details

#initialize(config:, theme:) ⇒ RenderGeometry

Returns a new instance of RenderGeometry.



7
8
9
10
# File 'lib/shellfie/render_geometry.rb', line 7

def initialize(config:, theme:)
  @config = config
  @theme = theme
end

Instance Method Details

#build(lines, scale:, shadow:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shellfie/render_geometry.rb', line 12

def build(lines, scale:, shadow:)
  font_config = @theme.font
  line_height = font_config[:size] * font_config[:line_height]
  display_lines, visible_count = display_lines(lines, font_config, line_height)
  total_height = title_bar_height + [visible_count, 1].max * line_height + padding * 2
  margin = canvas_margin(scale, shadow && !exact_size?)
  geometry = geometry_hash(
    display_lines,
    font_config,
    line_height,
    total_height,
    scale,
    margin,
    shadow && !exact_size?,
    visible_count
  )
  validate_pixel_limit!(geometry)
  geometry
end