Class: TG::Geometry::Line
- Inherits:
-
Object
- Object
- TG::Geometry::Line
- Defined in:
- ext/tg_geometry/tg_geometry_ext.c
Instance Method Summary collapse
- #bbox ⇒ Object
- #clockwise? ⇒ Boolean
- #length ⇒ Object
- #num_points ⇒ Object
- #num_segments ⇒ Object
- #point_at(index_value) ⇒ Object
- #points ⇒ Object
- #segment_at(index_value) ⇒ Object
- #segments ⇒ Object
Instance Method Details
#bbox ⇒ Object
1731 1732 1733 1734 1735 1736 1737 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1731
static VALUE rb_tg_geometry_line_bbox(VALUE self) {
tg_line_wrapper_t *w = get_line_wrapper(self);
VALUE rect = rect_from_tg_rect(tg_line_rect(w->line));
RB_GC_GUARD(self);
return rect;
}
|
#clockwise? ⇒ Boolean
1796 1797 1798 1799 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1796
static VALUE rb_tg_geometry_line_clockwise_p(VALUE self) {
tg_line_wrapper_t *w = get_line_wrapper(self);
return tg_line_clockwise(w->line) ? Qtrue : Qfalse;
}
|
#length ⇒ Object
1791 1792 1793 1794 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1791
static VALUE rb_tg_geometry_line_length(VALUE self) {
tg_line_wrapper_t *w = get_line_wrapper(self);
return rb_float_new(tg_line_length(w->line));
}
|
#num_points ⇒ Object
1739 1740 1741 1742 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1739
static VALUE rb_tg_geometry_line_num_points(VALUE self) {
tg_line_wrapper_t *w = get_line_wrapper(self);
return INT2NUM(tg_line_num_points(w->line));
}
|
#num_segments ⇒ Object
1765 1766 1767 1768 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1765
static VALUE rb_tg_geometry_line_num_segments(VALUE self) {
tg_line_wrapper_t *w = get_line_wrapper(self);
return INT2NUM(tg_line_num_segments(w->line));
}
|
#point_at(index_value) ⇒ Object
1744 1745 1746 1747 1748 1749 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1744
static VALUE rb_tg_geometry_line_point_at(VALUE self, VALUE index_value) {
tg_line_wrapper_t *w = get_line_wrapper(self);
int index = checked_child_index(index_value, tg_line_num_points(w->line), "line point");
return point_array_from_tg_point(tg_line_point_at(w->line, index));
}
|
#points ⇒ Object
1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1751
static VALUE rb_tg_geometry_line_points(VALUE self) {
tg_line_wrapper_t *w = get_line_wrapper(self);
int count = tg_line_num_points(w->line);
VALUE points = rb_ary_new_capa(count);
for (int i = 0; i < count; i++) {
rb_ary_push(points, point_array_from_tg_point(tg_line_point_at(w->line, i)));
}
RB_GC_GUARD(self);
RB_GC_GUARD(points);
return points;
}
|
#segment_at(index_value) ⇒ Object
1770 1771 1772 1773 1774 1775 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1770
static VALUE rb_tg_geometry_line_segment_at(VALUE self, VALUE index_value) {
tg_line_wrapper_t *w = get_line_wrapper(self);
int index = checked_child_index(index_value, tg_line_num_segments(w->line), "line segment");
return segment_wrap_value(tg_line_segment_at(w->line, index));
}
|
#segments ⇒ Object
1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1777
static VALUE rb_tg_geometry_line_segments(VALUE self) {
tg_line_wrapper_t *w = get_line_wrapper(self);
int count = tg_line_num_segments(w->line);
VALUE segments = rb_ary_new_capa(count);
for (int i = 0; i < count; i++) {
rb_ary_push(segments, segment_wrap_value(tg_line_segment_at(w->line, i)));
}
RB_GC_GUARD(self);
RB_GC_GUARD(segments);
return segments;
}
|