Module: Glimmer::LibUI::PerfectShaped
- Extended by:
- Forwardable
- Included in:
- ControlProxy::PathProxy, Shape
- Defined in:
- lib/glimmer/libui/perfect_shaped.rb
Overview
GUI View objects that can be represented by PerfectShape objects
Instance Method Summary collapse
-
#bounding_box ⇒ Object
Returns bounding box Array consisting of [minx, miny, width, height].
-
#contain?(*point, outline: false, distance_tolerance: 0) ⇒ Boolean
Returns if shape contains point on the inside when outline is false (default) or if point is on the outline when outline is true distance_tolerance is used when outline is true to enable a fuzz factor in determining if a point lies on the outline (e.g. makes it easier to select a shape by mouse).
-
#include?(*point) ⇒ Boolean
Returns if shape includes point on the inside when filled or if shape includes point on the outline when stroked.
- #move(x, y) ⇒ Object
-
#move_by(x_delta, y_delta) ⇒ Object
(also: #translate)
moves by x delta and y delta.
-
#perfect_shape ⇒ Object
Returns PerfectShape object matching this shape to enable executing computational geometry algorithms.
Instance Method Details
#bounding_box ⇒ Object
Returns bounding box Array consisting of
- minx, miny, width, height
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 33 def bounding_box perfect_shape_bounding_box = perfect_shape&.bounding_box return if perfect_shape_bounding_box.nil? [ perfect_shape_bounding_box.x, perfect_shape_bounding_box.y, perfect_shape_bounding_box.width, perfect_shape_bounding_box.height, ] end |
#contain?(*point, outline: false, distance_tolerance: 0) ⇒ Boolean
Returns if shape contains point on the inside when outline is false (default) or if point is on the outline when outline is true distance_tolerance is used when outline is true to enable a fuzz factor in determining if a point lies on the outline (e.g. makes it easier to select a shape by mouse)
17 18 19 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 17 def contain?(*point, outline: false, distance_tolerance: 0) perfect_shape&.contain?(*point, outline: outline, distance_tolerance: distance_tolerance) end |
#include?(*point) ⇒ Boolean
Returns if shape includes point on the inside when filled or if shape includes point on the outline when stroked
23 24 25 26 27 28 29 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 23 def include?(*point) if fill.empty? contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1)) else contain?(*point) end end |
#move(x, y) ⇒ Object
50 51 52 53 54 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 50 def move(x, y) x_delta = x - perfect_shape.min_x y_delta = y - perfect_shape.min_y move_by(x_delta, y_delta) end |
#move_by(x_delta, y_delta) ⇒ Object Also known as: translate
moves by x delta and y delta. Classes must implement
45 46 47 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 45 def move_by(x_delta, y_delta) # No Op end |
#perfect_shape ⇒ Object
Returns PerfectShape object matching this shape to enable executing computational geometry algorithms
Including classes must implement
60 61 62 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 60 def perfect_shape # No Op end |