Class: Glimmer::LibUI::Shape::Polybezier
- Inherits:
-
Glimmer::LibUI::Shape
- Object
- Glimmer::LibUI::Shape
- Glimmer::LibUI::Shape::Polybezier
- Defined in:
- lib/glimmer/libui/shape/polybezier.rb
Constant Summary
Constants inherited from Glimmer::LibUI::Shape
Instance Attribute Summary
Attributes inherited from Glimmer::LibUI::Shape
#args, #block, #content_added, #keyword, #parent
Instance Method Summary collapse
- #draw(area_draw_params) ⇒ Object
- #move_by(x_delta, y_delta) ⇒ Object
- #perfect_shape ⇒ Object
- #perfect_shape_dependencies ⇒ Object
Methods inherited from Glimmer::LibUI::Shape
#absolute_c1_x, #absolute_c1_y, #absolute_c2_x, #absolute_c2_y, #absolute_end_x, #absolute_end_y, #absolute_point_array, #absolute_x, #absolute_x_center, #absolute_y, #absolute_y_center, #area_proxy, #can_handle_listener?, #composite_shape, constant_symbol, #content, create, #destroy, exists?, #fill, #handle_listener, #implicit_path?, #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?, #move
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 |
# File 'lib/glimmer/libui/shape/polybezier.rb', line 31 def draw(area_draw_params) alternating_x_y_array = point_array.to_a.compact.flatten unless alternating_x_y_array.empty? ::LibUI.draw_path_new_figure(path_proxy.libui, alternating_x_y_array[0], alternating_x_y_array[1]) ((alternating_x_y_array.size - 2) / 6).times do |n| point_alternating_x_y_index = n * 6 ::LibUI.draw_path_bezier_to(path_proxy.libui, alternating_x_y_array[point_alternating_x_y_index + 2], alternating_x_y_array[point_alternating_x_y_index + 3], alternating_x_y_array[point_alternating_x_y_index + 4], alternating_x_y_array[point_alternating_x_y_index + 5], alternating_x_y_array[point_alternating_x_y_index + 6], alternating_x_y_array[point_alternating_x_y_index + 7]) end end super end |
#move_by(x_delta, y_delta) ⇒ Object
43 44 45 |
# File 'lib/glimmer/libui/shape/polybezier.rb', line 43 def move_by(x_delta, y_delta) self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta} end |
#perfect_shape ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/glimmer/libui/shape/polybezier.rb', line 47 def perfect_shape require 'perfect-shape' the_perfect_shape_dependencies = perfect_shape_dependencies if the_perfect_shape_dependencies != @perfect_shape_dependencies absolute_point_array = @perfect_shape_dependencies = the_perfect_shape_dependencies path_shapes = [absolute_point_array.first] bezier_shape_points = absolute_point_array.drop(1).each.with_index.to_a.group_by {|pair| pair.last/3}.values.map {|arr| arr.map(&:first)} path_shapes += bezier_shape_points.map { |points| PerfectShape::CubicBezierCurve.new(points: points) } @perfect_shape = PerfectShape::Path.new(closed: false, shapes: path_shapes) end @perfect_shape end |
#perfect_shape_dependencies ⇒ Object
60 61 62 |
# File 'lib/glimmer/libui/shape/polybezier.rb', line 60 def perfect_shape_dependencies absolute_point_array end |