Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.9 KiB

  1. /**************************************************************************
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * Main cycloid canvas paint procedure
  8. *
  9. * Created:
  10. *
  11. * 06/11/2000 asecchia
  12. * Created it.
  13. *
  14. **************************************************************************/
  15. #include "cycloid.hpp"
  16. #include "wndstuff.h"
  17. void HypoCycloid::Draw(Graphics *g, int x, int y, int width, int height)
  18. {
  19. #define _2PI 2*3.141592653689
  20. // Compute the center point for the cycle.
  21. float fXo=static_cast<float>(width)/2.0f;
  22. float fYo=static_cast<float>(height)/2.0f;
  23. float ScaleX = fXo/( (a>b)?a:a+b );
  24. float ScaleY = fYo/( (a>b)?a:a+b );
  25. int cycle=b/gcf(a,b); //number of times round the outer circle
  26. int Num = cycle*30;
  27. PointF *points = new PointF[Num];
  28. // Compute the points tracking the cycloid path.
  29. for(int i=0; i<Num; i++)
  30. {
  31. float t = (float)(cycle*_2PI*i/Num);
  32. points[i].X = x+(float)(fXo+ScaleX*((a-b)*cos(t)+b*cos((a-b)*t/b)));
  33. points[i].Y = y+(float)(fYo+ScaleY*((a-b)*sin(t)-b*sin((a-b)*t/b)));
  34. }
  35. Color PenColor(0xffff0000);
  36. Pen myPen(PenColor, 2.0f);
  37. myPen.SetLineJoin(LineJoinBevel);
  38. g->DrawPolygon(&myPen, points, Num);
  39. #undef _2PI
  40. }
  41. VOID
  42. PaintWindow(
  43. HDC hdc
  44. )
  45. {
  46. // Clear the window
  47. HGDIOBJ hbrush = GetStockObject(WHITE_BRUSH);
  48. HGDIOBJ holdBrush = SelectObject(hdc, hbrush);
  49. PatBlt(hdc, -10000, -10000, 20000, 20000, PATCOPY);
  50. SelectObject(hdc, holdBrush);
  51. DeleteObject(hbrush);
  52. Graphics *g = new Graphics(hdc);
  53. g->SetCompositingQuality(CompositingQualityGammaCorrected);
  54. g->SetSmoothingMode(SmoothingModeAntiAlias);
  55. // Do some stuff
  56. HypoCycloid *h = new HypoCycloid(52, 16);
  57. h->Draw(g, 10, 10, 400, 100);
  58. delete h;
  59. delete g;
  60. }