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
1701 1702 1703 1704 1705 1706 1707 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1701
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
1766 1767 1768 1769 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1766
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
1761 1762 1763 1764 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1761
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
1709 1710 1711 1712 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1709
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
1735 1736 1737 1738 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1735
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
1714 1715 1716 1717 1718 1719 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1714
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
1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1721
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
1740 1741 1742 1743 1744 1745 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1740
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
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 |
# File 'ext/tg_geometry/tg_geometry_ext.c', line 1747
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;
}
|