Class: Glimmer::LibUI::ImagePathRenderer

Inherits:
Object
  • Object
show all
Includes:
Glimmer
Defined in:
lib/glimmer/libui/image_path_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(area_proxy, shapes) ⇒ ImagePathRenderer

Returns a new instance of ImagePathRenderer.



6
7
8
9
# File 'lib/glimmer/libui/image_path_renderer.rb', line 6

def initialize(area_proxy, shapes)
  @area_proxy = area_proxy
  @shapes = shapes
end

Instance Method Details

#renderObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/glimmer/libui/image_path_renderer.rb', line 11

def render
  work = Proc.new do
    @shapes.each do |shape|
      path {
        rectangle(shape[:x], shape[:y], shape[:width], shape[:height])
    
        fill shape[:color]
      }
    end
  end
  if @area_proxy.nil?
    # Ensure it renders without a parent
    Glimmer::DSL::Engine.add_content(nil, Glimmer::DSL::Libui::ControlExpression.new, 'image', &work)
  else
    work.call
  end
end