home *** CD-ROM | disk | FTP | other *** search
/ Windows Graphics Programming / Feng_Yuan_Win32_GDI_DirectX.iso / Samples / include / axis.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-11  |  1.9 KB  |  56 lines

  1. #pragma once
  2.  
  3. //-----------------------------------------------------------------------------------//
  4. //              Windows Graphics Programming: Win32 GDI and DirectDraw               //
  5. //                             ISBN  0-13-086985-6                                   //
  6. //                                                                                   //
  7. //  Written            by  Yuan, Feng                             www.fengyuan.com   //
  8. //  Copyright (c) 2000 by  Hewlett-Packard Company                www.hp.com         //
  9. //  Published          by  Prentice Hall PTR, Prentice-Hall, Inc. www.phptr.com      //
  10. //                                                                                   //
  11. //  FileName   : axis.h                                                                 //
  12. //  Description: Arrow, axis drawing                                                 //
  13. //  Version    : 1.00.000, May 31, 2000                                              //
  14. //-----------------------------------------------------------------------------------//
  15.  
  16. class KRotate
  17. {
  18.     int m_x0, m_y0, m_dx, m_dy;
  19.  
  20. public:
  21.  
  22.     int m_ds;
  23.     
  24.     KRotate(int x0, int y0, int x1, int y1)
  25.     {
  26.         m_x0 = x0;
  27.         m_y0 = y0;
  28.         m_dx = x1 - x0;
  29.         m_dy = y1 - y0;
  30.         m_ds = (int) sqrt( m_dx * m_dx + m_dy * m_dy);
  31.     }
  32.  
  33.     int RotateX(int x, int y)
  34.     {
  35.         return x * m_dx / m_ds - y * m_dy / m_ds;
  36.     }
  37.  
  38.     int RotateY(int x, int y)
  39.     {
  40.         return x * m_dy / m_ds + y * m_dx / m_ds;
  41.     }
  42. };
  43.  
  44.  
  45. // Draw a line with an arrow    
  46. void Arrow(HDC hDC, int x0, int y0, int x1, int y1, int width, int height);
  47.  
  48. // Convert size in points to device coordinate
  49. void PointToDevice(HDC hDC, SIZE & size);
  50.  
  51. // Convert size in device coordinate to logical coordinate
  52. void DeviceToLogical(HDC hDC, SIZE & size);
  53.  
  54. // Generic algorithm for axes display: width height in device coordinate
  55. void ShowAxes(HDC hDC, int width, int height);
  56.