Class: Glimmer::LibUI::Shape::Line

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

Overview

Line to use as part of a figure (when having 2 args) or independently (when having 4 args representing start point x/y and end point x/y)

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, constant_symbol, #content, create, #destroy, exists?, #fill, #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 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



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

def draw(area_draw_params)
  if parent.is_a?(Figure)
    ::LibUI.draw_path_line_to(path_proxy.libui, x, y)
  else
    if include_start_point?
      ::LibUI.draw_path_new_figure(path_proxy.libui, x, y)
      ::LibUI.draw_path_line_to(path_proxy.libui, end_x, end_y)
    else
      ::LibUI.draw_path_new_figure(path_proxy.libui, 0, 0)
      ::LibUI.draw_path_line_to(path_proxy.libui, x, y)
    end
  end
  super
end

#include_start_point?Boolean

Indicates if line is not part of a figure and yet it includes the start point in addition to end point

Returns:

  • (Boolean)


49
50
51
52
53
54
# File 'lib/glimmer/libui/shape/line.rb', line 49

def include_start_point?
  # if the last 2 args are available, it means that the first 2 args represent the start point
  # if line is part of a figure, then the last 2 args are ignored and it is never assumed to include
  # start point
  !parent.is_a?(Figure) && end_x && end_y
end