Advertisement
Guest User

QTS no. 17 - Primitive rounded rectangle drawing function

a guest
Aug 18th, 2010
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.61 KB | None | 0 0
  1. /*
  2. -----------------------------------------
  3. * Game hacking QTS ( Quickie Tip Series )
  4. * no. 17 - Primitive rounded rectangle drawing function
  5. -----------------------------------------
  6. * Author: SEGnosis  - GHAnon.net
  7. * Thanks to:
  8. * bitterbanana      - No known site
  9. * Drunken Cheetah   - No known site
  10. * fatboy88      - No known site
  11. * Geek4Ever         - No known site
  12. * learn_more        - www.uc-forum.com
  13. * Novocaine         - http://ilsken.net/blog/?page_id=64
  14. * Philly0494        - No known site
  15. * Roverturbo        - www.uc-forum.com
  16. * SilentKarma       - www.halocoders.com - offline
  17. * Strife        - www.uc-forum.com
  18. * Wieter20      - No known site
  19. */
  20.  
  21. //----------------------------------//
  22. void Rounded( int x, int y, int w, int h, int iSmooth, D3DCOLOR Color )
  23. {
  24.     POINT pt[ 4 ];
  25.  
  26.     // Get all corners
  27.     pt[ 0 ].x = x + ( w - iSmooth );
  28.     pt[ 0 ].y = y + ( h - iSmooth );
  29.  
  30.     pt[ 1 ].x = x + iSmooth;
  31.     pt[ 1 ].y = y + ( h - iSmooth );
  32.  
  33.     pt[ 2 ].x = x + iSmooth;
  34.     pt[ 2 ].y = y + iSmooth;
  35.  
  36.     pt[ 3 ].x = x + w - iSmooth;
  37.     pt[ 3 ].y = y + iSmooth;
  38.  
  39.  
  40.     // Draw cross
  41.     CDraw.Rect( x, y + iSmooth, w, h - iSmooth * 2, Color );
  42.  
  43.     CDraw.Rect( x + iSmooth, y, w - iSmooth * 2, h, Color );
  44.  
  45.  
  46.     float fDegree = 0;
  47.  
  48.     for( int i = 0; i < 4; i++ )
  49.     {
  50.         for( float k = fDegree; k < fDegree + PI_SQUARED/4; k += D3DXToRadian( 1 ) )
  51.         {
  52.             // Draw quarter circles on every corner
  53.             CDraw.Line( pt[ i ].x, pt[ i ].y,
  54.                 pt[ i ].x + ( cosf( k ) * iSmooth ),
  55.                 pt[ i ].y + ( sinf( k ) * iSmooth ),
  56.                 3, Color ); // 3 is with line width
  57.         }
  58.  
  59.         fDegree += PI_SQUARED/4; // quarter circle offset
  60.     }
  61.  
  62. }
  63. //----------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement