Class: SFML::VertexArray
- Inherits:
-
Object
- Object
- SFML::VertexArray
- Defined in:
- ext/graphics/vertex_array.c,
ext/graphics/vertex_array.c
Overview
A resizable, drawable set of Vertex objects interpreted as a given primitive type (points, lines, triangles, ...).
Includes Drawable.
Instance Attribute Summary collapse
-
#primitive ⇒ Symbol
Returns the primitive type used to draw the vertices.
Instance Method Summary collapse
-
#append(vertex) ⇒ self
Appends
vertexto the array. -
#bounds ⇒ Rect
Returns the axis-aligned bounding box of all vertices.
-
#clear! ⇒ self
Removes all vertices.
-
#copy ⇒ VertexArray
Returns a deep copy of the object.
-
#draw(target, state) ⇒ nil
Part of the Drawable interface; call Target#draw instead of this directly.
-
#new ⇒ VertexArray
constructor
Creates a vertex array using the given
primitivetype. -
#resize(count) ⇒ self
Grows or shrinks the array to
countvertices; new vertices are default ones. -
#set_vertex(index, vertex) ⇒ Vertex
Replaces the vertex at
indexwithvertex. -
#vertex(index) ⇒ Vertex
Returns the vertex at
index. -
#vertex_count ⇒ Integer
Returns the number of vertices stored.
Constructor Details
#new ⇒ VertexArray
Creates a vertex array using the given primitive type.
57 58 59 |
# File 'ext/graphics/vertex_array.c', line 57 static VALUE VertexArray_initialize(VALUE self) { return self; } |
Instance Attribute Details
#primitive ⇒ Symbol
Returns the primitive type used to draw the vertices.
214 215 216 217 |
# File 'ext/graphics/vertex_array.c', line 214 static VALUE VertexArray_get_primitive_type(VALUE self) { return ID2SYM(rb_intern( primitive_type_name(sfVertexArray_getPrimitiveType(Get_VertexArray_Struct(self))))); } |
Instance Method Details
#append(vertex) ⇒ self
Appends vertex to the array.
128 129 130 131 |
# File 'ext/graphics/vertex_array.c', line 128
static VALUE VertexArray_append(VALUE self, VALUE rb_vertex) {
sfVertexArray_append(Get_VertexArray_Struct(self), vertex_from_rb(rb_vertex));
return self;
}
|
#bounds ⇒ Rect
Returns the axis-aligned bounding box of all vertices.
187 188 189 |
# File 'ext/graphics/vertex_array.c', line 187 static VALUE VertexArray_get_bounds(VALUE self) { return rect_to_rb(sfVertexArray_getBounds(Get_VertexArray_Struct(self))); } |
#clear! ⇒ self
Removes all vertices.
139 140 141 142 |
# File 'ext/graphics/vertex_array.c', line 139 static VALUE VertexArray_clear(VALUE self) { sfVertexArray_clear(Get_VertexArray_Struct(self)); return self; } |
#copy ⇒ VertexArray
Returns a deep copy of the object.
67 68 69 70 |
# File 'ext/graphics/vertex_array.c', line 67 static VALUE VertexArray_copy(VALUE self) { return VertexArray_wrap(Get_Klass_VertexArray(), sfVertexArray_copy(Get_VertexArray_Struct(self))); } |
#draw(target, state) ⇒ nil
Part of the Drawable interface; call Target#draw instead of this directly.
201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'ext/graphics/vertex_array.c', line 201
static VALUE VertexArray_draw(VALUE self, VALUE rb_target, VALUE rb_state) {
TargetView view = Get_RenderTarget_View(rb_target);
if (!rb_obj_is_kind_of(rb_state, Get_Klass_RenderState())) {
raise_invalid_argument_class(Get_Klass_RenderState());
}
TARGET_DRAW(view, sfRenderWindow_drawVertexArray, sfRenderTexture_drawVertexArray,
Get_VertexArray_Struct(self), Get_RenderState_Struct(rb_state));
return Qnil;
}
|
#resize(count) ⇒ self
Grows or shrinks the array to count vertices; new vertices are default
ones.
152 153 154 155 |
# File 'ext/graphics/vertex_array.c', line 152
static VALUE VertexArray_resize(VALUE self, VALUE rb_count) {
sfVertexArray_resize(Get_VertexArray_Struct(self), (size_t)NUM2SIZET(rb_count));
return self;
}
|
#set_vertex(index, vertex) ⇒ Vertex
Replaces the vertex at index with vertex.
115 116 117 118 119 |
# File 'ext/graphics/vertex_array.c', line 115
static VALUE VertexArray_set_vertex(VALUE self, VALUE rb_index, VALUE rb_vertex) {
*sfVertexArray_getVertex(Get_VertexArray_Struct(self),
VertexArray_check_index(self, rb_index)) = vertex_from_rb(rb_vertex);
return rb_vertex;
}
|
#vertex(index) ⇒ Vertex
Returns the vertex at index.
102 103 104 105 |
# File 'ext/graphics/vertex_array.c', line 102
static VALUE VertexArray_get_vertex(VALUE self, VALUE rb_index) {
return vertex_to_rb(*sfVertexArray_getVertex(Get_VertexArray_Struct(self),
VertexArray_check_index(self, rb_index)));
}
|
#vertex_count ⇒ Integer
Returns the number of vertices stored.
78 79 80 |
# File 'ext/graphics/vertex_array.c', line 78 static VALUE VertexArray_get_vertex_count(VALUE self) { return SIZET2NUM(sfVertexArray_getVertexCount(Get_VertexArray_Struct(self))); } |