MCPcopy Create free account
hub / github.com/SFML/SFML / update

Method update

src/SFML/Graphics/Shape.cpp:217–250  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

215
216////////////////////////////////////////////////////////////
217void Shape::update()
218{
219 // Get the total number of points of the shape
220 const std::size_t count = getPointCount();
221 if (count < 3)
222 {
223 m_vertices.clear();
224 m_outlineVertices.clear();
225 return;
226 }
227
228 m_vertices.resize(count + 2); // + 2 for center and repeated first point
229
230 // Position
231 for (std::size_t i = 0; i < count; ++i)
232 m_vertices[i + 1].position = getPoint(i);
233 m_vertices[count + 1].position = m_vertices[1].position;
234
235 // Update the bounding rectangle
236 m_vertices[0] = m_vertices[1]; // so that the result of getBounds() is correct
237 m_insideBounds = m_vertices.getBounds();
238
239 // Compute the center and make it the first vertex
240 m_vertices[0].position = m_insideBounds.getCenter();
241
242 // Color
243 updateFillColors();
244
245 // Texture coordinates
246 updateTexCoords();
247
248 // Outline
249 updateOutline();
250}
251
252
253////////////////////////////////////////////////////////////

Callers 5

Texture.test.cppFile · 0.45
loadGlyphMethod · 0.45
findGlyphRectMethod · 0.45

Calls 4

getBoundsMethod · 0.80
getCenterMethod · 0.80
clearMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected