MCPcopy Create free account
hub / github.com/cinder/Cinder / calcPreciseBoundingBox

Method calcPreciseBoundingBox

src/cinder/Path2d.cpp:1329–1374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1327}
1328
1329Rectf Path2d::calcPreciseBoundingBox() const
1330{
1331 if( mPoints.empty() )
1332 return Rectf();
1333 else if( mPoints.size() == 1 )
1334 return Rectf( mPoints[0], mPoints[0] );
1335 else if( mPoints.size() == 2 )
1336 return Rectf( mPoints[0], mPoints[1] );
1337
1338 Rectf result( mPoints[0], mPoints[0] );
1339 size_t firstPoint = 0;
1340 for( size_t s = 0; s < mSegments.size(); ++s ) {
1341 switch( mSegments[s] ) {
1342 case CUBICTO: {
1343 float monotoneT[4];
1344 int monotoneCnt = calcCubicBezierMonotoneRegions( &(mPoints[firstPoint]), monotoneT );
1345 for( int monotoneIdx = 0; monotoneIdx < monotoneCnt; ++monotoneIdx )
1346 result.include( calcCubicBezierPos( &(mPoints[firstPoint]), monotoneT[monotoneIdx] ) );
1347 result.include( mPoints[firstPoint+0] );
1348 result.include( mPoints[firstPoint+3] );
1349 }
1350 break;
1351 case QUADTO: {
1352 float monotoneT[2];
1353 int monotoneCnt = calcQuadraticBezierMonotoneRegions( &(mPoints[firstPoint]), monotoneT );
1354 for( int monotoneIdx = 0; monotoneIdx < monotoneCnt; ++monotoneIdx )
1355 result.include( calcQuadraticBezierPos( &(mPoints[firstPoint]), monotoneT[monotoneIdx] ) );
1356 result.include( mPoints[firstPoint+0] );
1357 result.include( mPoints[firstPoint+2] );
1358 }
1359 break;
1360 case LINETO:
1361 result.include( mPoints[firstPoint] );
1362 result.include( mPoints[firstPoint+1] );
1363 break;
1364 case CLOSE:
1365 break;
1366 default:
1367 throw Path2dExc();
1368 }
1369
1370 firstPoint += sSegmentTypePointCounts[mSegments[s]];
1371 }
1372
1373 return result;
1374}
1375
1376bool Path2d::calcClockwise() const
1377{

Callers 8

makeGeomMethod · 0.45
drawMethod · 0.45
loadSvgMethod · 0.45
updatePathSubdivisionMethod · 0.45
path2dpart3.jsFile · 0.45
path2dpart2.jsFile · 0.45
path2dpart1.jsFile · 0.45
calcBoundingBoxFunction · 0.45

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
includeMethod · 0.45

Tested by

no test coverage detected