Guest User

Untitled

a guest
May 21st, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. painter->setPen(pen());
  2. painter->setBrush(brush());
  3.  
  4. //====== CAN I GAIN PERFORMANCE BOOST WITH THAT ???
  5. if ( m_isCompleted )
  6. {
  7. painter->drawPath( m_shapePath );
  8. return;
  9. }
  10. //=================================================
  11.  
  12. QPainterPath path;
  13. float p1X = -1;
  14. float p1Y = -1;
  15. float p2X = -1;
  16. float p2Y = -1;
  17. float pEndX = -1;
  18. float pEndY = -1;
  19.  
  20. for ( int i = 1; i < m_points->size()-1; i++ )
  21. {
  22. if ( i == 1 )
  23. {
  24. path.moveTo( m_points->at( 0 ) );
  25. }
  26. p1X = m_points->at( i ).x();
  27. p1Y = m_points->at( i ).y();
  28. p2X = m_points->at( i+1 ).x();
  29. p2Y = m_points->at( i+1 ).y();
  30. if ( m_isCurved )
  31. {
  32. pEndX = p1X + ( p2X - p1X ) / 2;
  33. pEndY = p1Y + ( p2Y - p1Y ) / 2;
  34. path.quadTo( p1X, p1Y, pEndX, pEndY );
  35. path.moveTo( pEndX, pEndY ); // is a must for collision detection
  36. }
  37. else
  38. {
  39. path.lineTo( p1X, p1Y );
  40. path.moveTo( p1X, p1Y ); // is a must for collision detection
  41. }
  42. }
  43.  
  44. m_shapePath = path;
  45. painter->drawPath( path );
Add Comment
Please, Sign In to add comment