Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- painter->setPen(pen());
- painter->setBrush(brush());
- //====== CAN I GAIN PERFORMANCE BOOST WITH THAT ???
- if ( m_isCompleted )
- {
- painter->drawPath( m_shapePath );
- return;
- }
- //=================================================
- QPainterPath path;
- float p1X = -1;
- float p1Y = -1;
- float p2X = -1;
- float p2Y = -1;
- float pEndX = -1;
- float pEndY = -1;
- for ( int i = 1; i < m_points->size()-1; i++ )
- {
- if ( i == 1 )
- {
- path.moveTo( m_points->at( 0 ) );
- }
- p1X = m_points->at( i ).x();
- p1Y = m_points->at( i ).y();
- p2X = m_points->at( i+1 ).x();
- p2Y = m_points->at( i+1 ).y();
- if ( m_isCurved )
- {
- pEndX = p1X + ( p2X - p1X ) / 2;
- pEndY = p1Y + ( p2Y - p1Y ) / 2;
- path.quadTo( p1X, p1Y, pEndX, pEndY );
- path.moveTo( pEndX, pEndY ); // is a must for collision detection
- }
- else
- {
- path.lineTo( p1X, p1Y );
- path.moveTo( p1X, p1Y ); // is a must for collision detection
- }
- }
- m_shapePath = path;
- painter->drawPath( path );
Add Comment
Please, Sign In to add comment