Module: Glimmer::LibUI::PerfectShaped
- 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.
-
#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
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 26 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)
10 11 12 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 10 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
16 17 18 19 20 21 22 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 16 def include?(*point) if fill.empty? contain?(*point, outline: true, distance_tolerance: ((stroke[:thickness] || 1) - 1)) else contain?(*point) end end |
#perfect_shape ⇒ Object
Returns PerfectShape object matching this shape to enable executing computational geometry algorithms
Including classes must implement
41 42 43 |
# File 'lib/glimmer/libui/perfect_shaped.rb', line 41 def perfect_shape # No Op end |