Class: Glimmer::LibUI::Shape::Arc

Inherits:
Glimmer::LibUI::Shape show all
Defined in:
lib/glimmer/libui/shape/arc.rb

Instance Attribute Summary

Attributes inherited from Glimmer::LibUI::Shape

#args, #block, #content_added, #keyword, #parent

Instance Method Summary collapse

Methods inherited from Glimmer::LibUI::Shape

#area_proxy, #can_handle_listener?, constant_symbol, #content, create, #destroy, exists?, #fill, #handle_listener, #initialize, #method_missing, parameter_defaults, parameters, #path_proxy, #post_add_content, #post_initialize_child, #redraw, #request_auto_redraw, #respond_to?, shape_class, #stroke, #transform

Methods included from DataBindable

#data_bind, #data_bind_read, #data_bind_write, #data_binding_model_attribute_observer_registrations

Methods included from PerfectShaped

#bounding_box, #contain?, #include?

Methods included from Parent

#children, #post_initialize_child

Constructor Details

This class inherits a constructor from Glimmer::LibUI::Shape

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::LibUI::Shape

Instance Method Details

#draw(area_draw_params) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/glimmer/libui/shape/arc.rb', line 31

def draw(area_draw_params)
  arc_args = @args.dup
  arc_args[3] = Glimmer::LibUI.degrees_to_radians(arc_args[3])
  arc_args[4] = Glimmer::LibUI.degrees_to_radians(arc_args[4])
  arc_args[5] = Glimmer::LibUI.boolean_to_integer(arc_args[5], allow_nil: false)
  if parent.is_a?(Figure) && parent.x.nil? && parent.y.nil?
    ::LibUI.draw_path_new_figure_with_arc(path_proxy.libui, *arc_args)
  else
    if OS.windows? && parent.children.find {|child| child.is_a?(Arc)} == self
      ::LibUI.draw_path_new_figure_with_arc(path_proxy.libui, *arc_args)
    else
      ::LibUI.draw_path_arc_to(path_proxy.libui, *arc_args)
    end
  end
  super
end

#perfect_shapeObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/glimmer/libui/shape/arc.rb', line 48

def perfect_shape
  perfect_shape_dependencies = [x_center, y_center, radius, start_angle, sweep, is_negative]
  if perfect_shape_dependencies != @perfect_shape_dependencies
    x_center, y_center, radius, start_angle, sweep, is_negative = @perfect_shape_dependencies = perfect_shape_dependencies
    sign = is_negative ? 1 : -1
    start = is_negative ? (360 - start_angle) : -1*start_angle
    extent = is_negative ? (360 - sweep) : -1*sweep
    @perfect_shape = PerfectShape::Arc.new(
      type: :open,
      center_x: x_center, center_y: y_center,
      radius_x: radius, radius_y: radius,
      start: start, extent: extent
    )
  end
  @perfect_shape
end