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.

67 lines
1.8 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: CRegions.cpp
  3. *
  4. * This file contains the code to support the functionality test harness
  5. * for GDI+. This includes menu options and calling the appropriate
  6. * functions for execution.
  7. *
  8. * Created: 05-May-2000 - Jeff Vezina [t-jfvez]
  9. *
  10. * Copyright (c) 2000 Microsoft Corporation
  11. *
  12. \**************************************************************************/
  13. #include "CRegions.h"
  14. #include <math.h>
  15. CRegions::CRegions(BOOL bRegression)
  16. {
  17. strcpy(m_szName,"Regions");
  18. m_bRegression=bRegression;
  19. }
  20. CRegions::~CRegions()
  21. {
  22. }
  23. void CRegions::Draw(Graphics *g)
  24. {
  25. REAL width = 2; // Pen width
  26. PointF points[5];
  27. REAL s, c, theta;
  28. REAL pi = 3.1415926535897932f;
  29. PointF orig((int)(TESTAREAWIDTH/2.0f), (int)(TESTAREAHEIGHT/2.0f));
  30. theta = -pi/2;
  31. // Create a star shape.
  32. for(INT i = 0; i < 5; i++)
  33. {
  34. s = sinf(theta);
  35. c = cosf(theta);
  36. points[i].X = (int)(125.0f/250.0f*TESTAREAWIDTH)*c + orig.X;
  37. points[i].Y = (int)(125.0f/250.0f*TESTAREAHEIGHT)*s + orig.Y;
  38. theta += 0.8f*pi;
  39. }
  40. Color orangeColor(128, 255, 180, 0);
  41. SolidBrush orangeBrush(orangeColor);
  42. GraphicsPath* path = new GraphicsPath(FillModeAlternate);
  43. // Path* path = new GraphicsPath(Winding);
  44. path->AddPolygon(points, 5);
  45. Color blackColor(0, 0, 0);
  46. SolidBrush blackBrush(blackColor);
  47. Pen blackPen(&blackBrush, width);
  48. Region * region = new Region(path);
  49. g->FillRegion(&orangeBrush, region); // There is a BUG!
  50. // g->FillGraphicsPath(&orangeBrush, path); // Fill path works fine.
  51. blackPen.SetLineJoin(LineJoinMiter);
  52. g->DrawPath(&blackPen, path);
  53. delete path;
  54. delete region;
  55. }