Class: TG::Geometry::Ring
- Inherits:
-
Object
- Object
- TG::Geometry::Ring
- Defined in:
- ext/tg_geometry/tg_geometry_ext.c
Instance Method Summary collapse
- #area ⇒ Object
- #bbox ⇒ Object
- #clockwise? ⇒ Boolean
- #convex? ⇒ Boolean
- #num_points ⇒ Object
- #num_segments ⇒ Object
- #perimeter ⇒ Object
- #point_at(index_value) ⇒ Object
- #points ⇒ Object
- #segment_at(index_value) ⇒ Object
- #segments ⇒ Object
Instance Method Details
#area ⇒ Object
1831 1832 1833 1834 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1831
static VALUE rb_tg_geometry_ring_area(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
return rb_float_new(tg_ring_area(w->ring));
}
|
#bbox ⇒ Object
1771 1772 1773 1774 1775 1776 1777 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1771
static VALUE rb_tg_geometry_ring_bbox(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
VALUE rect = rect_from_tg_rect(tg_ring_rect(w->ring));
RB_GC_GUARD(self);
return rect;
}
|
#clockwise? ⇒ Boolean
1841 1842 1843 1844 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1841
static VALUE rb_tg_geometry_ring_clockwise_p(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
return tg_ring_clockwise(w->ring) ? Qtrue : Qfalse;
}
|
#convex? ⇒ Boolean
1846 1847 1848 1849 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1846
static VALUE rb_tg_geometry_ring_convex_p(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
return tg_ring_convex(w->ring) ? Qtrue : Qfalse;
}
|
#num_points ⇒ Object
1779 1780 1781 1782 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1779
static VALUE rb_tg_geometry_ring_num_points(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
return INT2NUM(tg_ring_num_points(w->ring));
}
|
#num_segments ⇒ Object
1805 1806 1807 1808 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1805
static VALUE rb_tg_geometry_ring_num_segments(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
return INT2NUM(tg_ring_num_segments(w->ring));
}
|
#perimeter ⇒ Object
1836 1837 1838 1839 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1836
static VALUE rb_tg_geometry_ring_perimeter(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
return rb_float_new(tg_ring_perimeter(w->ring));
}
|
#point_at(index_value) ⇒ Object
1784 1785 1786 1787 1788 1789 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1784
static VALUE rb_tg_geometry_ring_point_at(VALUE self, VALUE index_value) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
int index = checked_child_index(index_value, tg_ring_num_points(w->ring), "ring point");
return point_array_from_tg_point(tg_ring_point_at(w->ring, index));
}
|
#points ⇒ Object
1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1791
static VALUE rb_tg_geometry_ring_points(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
int count = tg_ring_num_points(w->ring);
VALUE points = rb_ary_new_capa(count);
for (int i = 0; i < count; i++) {
rb_ary_push(points, point_array_from_tg_point(tg_ring_point_at(w->ring, i)));
}
RB_GC_GUARD(self);
RB_GC_GUARD(points);
return points;
}
|
#segment_at(index_value) ⇒ Object
1810 1811 1812 1813 1814 1815 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1810
static VALUE rb_tg_geometry_ring_segment_at(VALUE self, VALUE index_value) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
int index = checked_child_index(index_value, tg_ring_num_segments(w->ring), "ring segment");
return segment_wrap_value(tg_ring_segment_at(w->ring, index));
}
|
#segments ⇒ Object
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1817
static VALUE rb_tg_geometry_ring_segments(VALUE self) {
tg_ring_wrapper_t *w = get_ring_wrapper(self);
int count = tg_ring_num_segments(w->ring);
VALUE segments = rb_ary_new_capa(count);
for (int i = 0; i < count; i++) {
rb_ary_push(segments, segment_wrap_value(tg_ring_segment_at(w->ring, i)));
}
RB_GC_GUARD(self);
RB_GC_GUARD(segments);
return segments;
}
|