Class: LibUI::Path
- Inherits:
-
Object
- Object
- LibUI::Path
- Defined in:
- lib/libui/path.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_rectangle(x, y, width, height) ⇒ Object
- #arc_to(x, y, radius, start_angle, sweep, negative = false) ⇒ Object
- #bezier_to(c1x, c1y, c2x, c2y, end_x, end_y) ⇒ Object
- #close ⇒ Object
- #close_figure ⇒ Object
- #end_path ⇒ Object
-
#initialize(fill_mode = DrawFillModeWinding) ⇒ Path
constructor
A new instance of Path.
- #line_to(x, y) ⇒ Object
- #new_figure(x, y) ⇒ Object
- #new_figure_with_arc(x, y, radius, start_angle, sweep, negative = false) ⇒ Object
- #to_ptr ⇒ Object
Constructor Details
#initialize(fill_mode = DrawFillModeWinding) ⇒ Path
Returns a new instance of Path.
12 13 14 |
# File 'lib/libui/path.rb', line 12 def initialize(fill_mode = DrawFillModeWinding) @pointer = LibUI.draw_new_path(fill_mode) end |
Class Method Details
.open(fill_mode = DrawFillModeWinding) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/libui/path.rb', line 3 def self.open(fill_mode = DrawFillModeWinding) path = new(fill_mode) begin yield path ensure path.close end end |
Instance Method Details
#add_rectangle(x, y, width, height) ⇒ Object
52 53 54 55 |
# File 'lib/libui/path.rb', line 52 def add_rectangle(x, y, width, height) LibUI.draw_path_add_rectangle(to_ptr, x, y, width, height) self end |
#arc_to(x, y, radius, start_angle, sweep, negative = false) ⇒ Object
37 38 39 40 |
# File 'lib/libui/path.rb', line 37 def arc_to(x, y, radius, start_angle, sweep, negative = false) LibUI.draw_path_arc_to(to_ptr, x, y, radius, start_angle, sweep, negative ? 1 : 0) self end |
#bezier_to(c1x, c1y, c2x, c2y, end_x, end_y) ⇒ Object
42 43 44 45 |
# File 'lib/libui/path.rb', line 42 def bezier_to(c1x, c1y, c2x, c2y, end_x, end_y) LibUI.draw_path_bezier_to(to_ptr, c1x, c1y, c2x, c2y, end_x, end_y) self end |
#close ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/libui/path.rb', line 62 def close return if @pointer.nil? LibUI.draw_free_path(@pointer) @pointer = nil nil end |
#close_figure ⇒ Object
47 48 49 50 |
# File 'lib/libui/path.rb', line 47 def close_figure LibUI.draw_path_close_figure(to_ptr) self end |
#end_path ⇒ Object
57 58 59 60 |
# File 'lib/libui/path.rb', line 57 def end_path LibUI.draw_path_end(to_ptr) self end |
#line_to(x, y) ⇒ Object
32 33 34 35 |
# File 'lib/libui/path.rb', line 32 def line_to(x, y) LibUI.draw_path_line_to(to_ptr, x, y) self end |
#new_figure(x, y) ⇒ Object
22 23 24 25 |
# File 'lib/libui/path.rb', line 22 def new_figure(x, y) LibUI.draw_path_new_figure(to_ptr, x, y) self end |
#new_figure_with_arc(x, y, radius, start_angle, sweep, negative = false) ⇒ Object
27 28 29 30 |
# File 'lib/libui/path.rb', line 27 def new_figure_with_arc(x, y, radius, start_angle, sweep, negative = false) LibUI.draw_path_new_figure_with_arc(to_ptr, x, y, radius, start_angle, sweep, negative ? 1 : 0) self end |
#to_ptr ⇒ Object
16 17 18 19 20 |
# File 'lib/libui/path.rb', line 16 def to_ptr raise RuntimeError, 'draw path is closed' unless @pointer @pointer end |