MCPcopy Create free account
hub / github.com/SpartanJ/eepp / updateVertex

Method updateVertex

src/eepp/graphics/rectangledrawable.cpp:173–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173void RectangleDrawable::updateVertex() {
174 if ( mCorners == 0 )
175 return;
176
177 prepareVertexBuffer( mFillMode == DRAW_LINE ? PRIMITIVE_LINE_LOOP : PRIMITIVE_TRIANGLE_FAN );
178
179 unsigned int i;
180 Sizef size = mSize;
181 Float xscalediff = size.getWidth() * mScale.x - size.getWidth();
182 Float yscalediff = size.getHeight() * mScale.y - size.getHeight();
183 Vector2f Center( mPosition.x + size.getWidth() * 0.5f + xscalediff,
184 mPosition.y + size.getHeight() * 0.5f + yscalediff );
185 Polygon2f Poly = Polygon2f::createRoundedRectangle(
186 mPosition.x - xscalediff, mPosition.y - yscalediff, size.getWidth() + xscalediff,
187 size.getHeight() + yscalediff, mCorners );
188 Vector2f poly;
189 Poly.rotate( mRotation, Center );
190
191 if ( !mUsingRectColors ) {
192 for ( i = 0; i < Poly.getSize(); i++ ) {
193 mVertexBuffer->addVertex( Poly[i] );
194 mVertexBuffer->addColor( mColor );
195 }
196 } else {
197 for ( i = 0; i < Poly.getSize(); i++ ) {
198 poly = Poly[i];
199
200 if ( poly.x <= Center.x && poly.y <= Center.y )
201 mVertexBuffer->addColor( mRectColors.TopLeft );
202 else if ( poly.x <= Center.x && poly.y >= Center.y )
203 mVertexBuffer->addColor( mRectColors.BottomLeft );
204 else if ( poly.x > Center.x && poly.y > Center.y )
205 mVertexBuffer->addColor( mRectColors.BottomRight );
206 else if ( poly.x > Center.x && poly.y < Center.y )
207 mVertexBuffer->addColor( mRectColors.TopRight );
208 else
209 mVertexBuffer->addColor( mRectColors.TopLeft );
210
211 mVertexBuffer->addVertex( poly );
212 }
213 }
214
215 mNeedsUpdate = false;
216}
217
218void RectangleDrawable::onColorFilterChange() {
219 PrimitiveDrawable::onColorFilterChange();

Callers

nothing calls this directly

Calls 6

addVertexMethod · 0.80
addColorMethod · 0.80
getWidthMethod · 0.45
getHeightMethod · 0.45
rotateMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected