Class: Glimmer::LibUI::Shape::Bezier
- Inherits:
-
Glimmer::LibUI::Shape
- Object
- Glimmer::LibUI::Shape
- Glimmer::LibUI::Shape::Bezier
- Defined in:
- lib/glimmer/libui/shape/bezier.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
-
#include_start_point? ⇒ Boolean
Indicates if bezier is not part of a figure and yet it includes the start point in addition to other points.
-
#initialize(keyword, parent, args, &block) ⇒ Bezier
constructor
A new instance of Bezier.
- #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?, #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
#initialize(keyword, parent, args, &block) ⇒ Bezier
Returns a new instance of Bezier.
31 32 33 34 |
# File 'lib/glimmer/libui/shape/bezier.rb', line 31 def initialize(keyword, parent, args, &block) args.prepend nil until args.size == 8 super(keyword, parent, args, &block) end |
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
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/glimmer/libui/shape/bezier.rb', line 36 def draw(area_draw_params) if !parent.is_a?(Figure) if include_start_point? ::LibUI.draw_path_new_figure(path_proxy.libui, x, y) else ::LibUI.draw_path_new_figure(path_proxy.libui, 0, 0) end end ::LibUI.draw_path_bezier_to(path_proxy.libui, c1_x, c1_y, c2_x, c2_y, end_x, end_y) super end |
#include_start_point? ⇒ Boolean
Indicates if bezier is not part of a figure and yet it includes the start point in addition to other points
49 50 51 |
# File 'lib/glimmer/libui/shape/bezier.rb', line 49 def include_start_point? x && y end |
#move_by(x_delta, y_delta) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/glimmer/libui/shape/bezier.rb', line 53 def move_by(x_delta, y_delta) self.x += x_delta self.y += y_delta self.c1_x += x_delta self.c1_y += y_delta self.c2_x += x_delta self.c2_y += y_delta self.end_x += x_delta self.end_y += y_delta end |
#perfect_shape ⇒ Object
64 65 66 67 68 69 70 71 72 |
# File 'lib/glimmer/libui/shape/bezier.rb', line 64 def perfect_shape require 'perfect-shape' the_perfect_shape_dependencies = perfect_shape_dependencies if the_perfect_shape_dependencies != @perfect_shape_dependencies absolute_x, absolute_y, absolute_c1_x, absolute_c1_y, absolute_c2_x, absolute_c2_y, absolute_end_x, absolute_end_y = @perfect_shape_dependencies = the_perfect_shape_dependencies @perfect_shape = PerfectShape::CubicBezierCurve.new(points: [absolute_x, absolute_y, absolute_c1_x, absolute_c1_y, absolute_c2_x, absolute_c2_y, absolute_end_x, absolute_end_y].compact) end @perfect_shape end |
#perfect_shape_dependencies ⇒ Object
74 75 76 |
# File 'lib/glimmer/libui/shape/bezier.rb', line 74 def perfect_shape_dependencies [absolute_x, absolute_y, absolute_c1_x, absolute_c1_y, absolute_c2_x, absolute_c2_y, absolute_end_x, absolute_end_y] end |