Class: Skia::Path
Instance Attribute Summary
Attributes inherited from Base
#ptr
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add_arc(rect, start_angle, sweep_angle) ⇒ Object
-
#add_circle(cx, cy, radius, direction = :cw) ⇒ Object
-
#add_oval(rect, direction = :cw) ⇒ Object
-
#add_path(other, extend_path: false) ⇒ Object
-
#add_path_matrix(other, matrix, extend_path: false) ⇒ Object
-
#add_path_offset(other, dx, dy, extend_path: false) ⇒ Object
-
#add_path_reverse(other) ⇒ Object
-
#add_rect(rect, direction = :cw) ⇒ Object
-
#add_rrect(rrect, direction = :cw) ⇒ Object
-
#approximate_length(force_closed: false, res_scale: 1.0) ⇒ Object
-
#arc_to(rx, ry, x_axis_rotate, x, y) ⇒ Object
-
#arc_to_with_oval(oval, start_angle, sweep_angle, force_move_to = false) ⇒ Object
-
#bounds ⇒ Object
-
#clone ⇒ Object
-
#close ⇒ Object
-
#conic_to(x1, y1, x2, y2, weight) ⇒ Object
-
#contains?(x, y) ⇒ Boolean
-
#count_points ⇒ Object
-
#cubic_to(x1, y1, x2, y2, x3, y3) ⇒ Object
-
#empty? ⇒ Boolean
-
#fill_type ⇒ Object
-
#fill_type=(value) ⇒ Object
-
#initialize(ptr = nil) ⇒ Path
constructor
-
#line_to(x, y) ⇒ Object
-
#move_to(x, y) ⇒ Object
-
#quad_to(x1, y1, x2, y2) ⇒ Object
-
#reset ⇒ Object
-
#reverse ⇒ Object
-
#transform(matrix) ⇒ Object
Methods inherited from Base
#null?, release_callback, #to_ptr
Constructor Details
#initialize(ptr = nil) ⇒ Path
Returns a new instance of Path.
5
6
7
|
# File 'lib/skia/path.rb', line 5
def initialize(ptr = nil)
super(ptr || Native.sk_path_new, :sk_path_delete)
end
|
Class Method Details
.build(&block) ⇒ Object
9
10
11
12
13
|
# File 'lib/skia/path.rb', line 9
def self.build(&block)
path = new
path.instance_eval(&block) if block
path
end
|
Instance Method Details
#add_arc(rect, start_angle, sweep_angle) ⇒ Object
78
79
80
81
82
|
# File 'lib/skia/path.rb', line 78
def add_arc(rect, start_angle, sweep_angle)
rect_struct = rect.to_struct
Native.sk_path_add_arc(@ptr, rect_struct, start_angle.to_f, sweep_angle.to_f)
self
end
|
#add_circle(cx, cy, radius, direction = :cw) ⇒ Object
73
74
75
76
|
# File 'lib/skia/path.rb', line 73
def add_circle(cx, cy, radius, direction = :cw)
Native.sk_path_add_circle(@ptr, cx.to_f, cy.to_f, radius.to_f, direction)
self
end
|
#add_oval(rect, direction = :cw) ⇒ Object
67
68
69
70
71
|
# File 'lib/skia/path.rb', line 67
def add_oval(rect, direction = :cw)
rect_struct = rect.to_struct
Native.sk_path_add_oval(@ptr, rect_struct, direction)
self
end
|
#add_path(other, extend_path: false) ⇒ Object
84
85
86
87
88
|
# File 'lib/skia/path.rb', line 84
def add_path(other, extend_path: false)
mode = extend_path ? 1 : 0
Native.sk_path_add_path(@ptr, other.ptr, mode, 0)
self
end
|
#add_path_matrix(other, matrix, extend_path: false) ⇒ Object
101
102
103
104
105
106
|
# File 'lib/skia/path.rb', line 101
def add_path_matrix(other, matrix, extend_path: false)
mode = extend_path ? 1 : 0
matrix_struct = matrix.to_struct
Native.sk_path_add_path_matrix(@ptr, other.ptr, matrix_struct, mode)
self
end
|
#add_path_offset(other, dx, dy, extend_path: false) ⇒ Object
90
91
92
93
94
|
# File 'lib/skia/path.rb', line 90
def add_path_offset(other, dx, dy, extend_path: false)
mode = extend_path ? 1 : 0
Native.sk_path_add_path_offset(@ptr, other.ptr, dx.to_f, dy.to_f, mode)
self
end
|
#add_path_reverse(other) ⇒ Object
96
97
98
99
|
# File 'lib/skia/path.rb', line 96
def add_path_reverse(other)
Native.sk_path_add_path_reverse(@ptr, other.ptr)
self
end
|
#add_rect(rect, direction = :cw) ⇒ Object
56
57
58
59
60
|
# File 'lib/skia/path.rb', line 56
def add_rect(rect, direction = :cw)
rect_struct = rect.to_struct
Native.sk_path_add_rect(@ptr, rect_struct, direction)
self
end
|
#add_rrect(rrect, direction = :cw) ⇒ Object
62
63
64
65
|
# File 'lib/skia/path.rb', line 62
def add_rrect(rrect, direction = :cw)
Native.sk_path_add_rrect(@ptr, rrect.ptr, direction)
self
end
|
#approximate_length(force_closed: false, res_scale: 1.0) ⇒ Object
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/skia/path.rb', line 130
def approximate_length(force_closed: false, res_scale: 1.0)
measure = Native.sk_pathmeasure_new_with_path(@ptr, force_closed, res_scale.to_f)
raise Error, 'Failed to create path measure' if measure.nil? || measure.null?
begin
Native.sk_pathmeasure_get_length(measure)
ensure
Native.sk_pathmeasure_destroy(measure)
end
end
|
#arc_to(rx, ry, x_axis_rotate, x, y) ⇒ Object
40
41
42
43
|
# File 'lib/skia/path.rb', line 40
def arc_to(rx, ry, x_axis_rotate, x, y)
Native.sk_path_arc_to(@ptr, rx.to_f, ry.to_f, x_axis_rotate.to_f, x.to_f, y.to_f)
self
end
|
#arc_to_with_oval(oval, start_angle, sweep_angle, force_move_to = false) ⇒ Object
45
46
47
48
49
|
# File 'lib/skia/path.rb', line 45
def arc_to_with_oval(oval, start_angle, sweep_angle, force_move_to = false)
rect_struct = oval.to_struct
Native.sk_path_arc_to_with_oval(@ptr, rect_struct, start_angle.to_f, sweep_angle.to_f, force_move_to)
self
end
|
#bounds ⇒ Object
116
117
118
119
120
|
# File 'lib/skia/path.rb', line 116
def bounds
rect_struct = Native::SKRect.new
Native.sk_path_get_bounds(@ptr, rect_struct)
Rect.from_struct(rect_struct)
end
|
#clone ⇒ Object
151
152
153
|
# File 'lib/skia/path.rb', line 151
def clone
self.class.new(Native.sk_path_clone(@ptr))
end
|
#close ⇒ Object
51
52
53
54
|
# File 'lib/skia/path.rb', line 51
def close
Native.sk_path_close(@ptr)
self
end
|
#conic_to(x1, y1, x2, y2, weight) ⇒ Object
30
31
32
33
|
# File 'lib/skia/path.rb', line 30
def conic_to(x1, y1, x2, y2, weight)
Native.sk_path_conic_to(@ptr, x1.to_f, y1.to_f, x2.to_f, y2.to_f, weight.to_f)
self
end
|
#contains?(x, y) ⇒ Boolean
141
142
143
|
# File 'lib/skia/path.rb', line 141
def contains?(x, y)
Native.sk_path_contains(@ptr, x.to_f, y.to_f)
end
|
#count_points ⇒ Object
126
127
128
|
# File 'lib/skia/path.rb', line 126
def count_points
Native.sk_path_count_points(@ptr)
end
|
#cubic_to(x1, y1, x2, y2, x3, y3) ⇒ Object
35
36
37
38
|
# File 'lib/skia/path.rb', line 35
def cubic_to(x1, y1, x2, y2, x3, y3)
Native.sk_path_cubic_to(@ptr, x1.to_f, y1.to_f, x2.to_f, y2.to_f, x3.to_f, y3.to_f)
self
end
|
#empty? ⇒ Boolean
122
123
124
|
# File 'lib/skia/path.rb', line 122
def empty?
Native.sk_path_count_verbs(@ptr) == 0
end
|
#fill_type ⇒ Object
108
109
110
|
# File 'lib/skia/path.rb', line 108
def fill_type
Native.sk_path_get_filltype(@ptr)
end
|
#fill_type=(value) ⇒ Object
112
113
114
|
# File 'lib/skia/path.rb', line 112
def fill_type=(value)
Native.sk_path_set_filltype(@ptr, value)
end
|
#line_to(x, y) ⇒ Object
20
21
22
23
|
# File 'lib/skia/path.rb', line 20
def line_to(x, y)
Native.sk_path_line_to(@ptr, x.to_f, y.to_f)
self
end
|
#move_to(x, y) ⇒ Object
15
16
17
18
|
# File 'lib/skia/path.rb', line 15
def move_to(x, y)
Native.sk_path_move_to(@ptr, x.to_f, y.to_f)
self
end
|
#quad_to(x1, y1, x2, y2) ⇒ Object
25
26
27
28
|
# File 'lib/skia/path.rb', line 25
def quad_to(x1, y1, x2, y2)
Native.sk_path_quad_to(@ptr, x1.to_f, y1.to_f, x2.to_f, y2.to_f)
self
end
|
#reset ⇒ Object
161
162
163
164
|
# File 'lib/skia/path.rb', line 161
def reset
Native.sk_path_reset(@ptr)
self
end
|
#reverse ⇒ Object
155
156
157
158
159
|
# File 'lib/skia/path.rb', line 155
def reverse
reversed = self.class.new
Native.sk_path_add_path_reverse(reversed.ptr, @ptr)
reversed
end
|
145
146
147
148
149
|
# File 'lib/skia/path.rb', line 145
def transform(matrix)
matrix_struct = matrix.to_struct
Native.sk_path_transform(@ptr, matrix_struct)
self
end
|