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.

281 lines
6.3 KiB

  1. /**************************************************************************
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * <an unabbreviated name for the module (not the filename)>
  8. *
  9. * Abstract:
  10. *
  11. * <Description of what this module does>
  12. *
  13. * Notes:
  14. *
  15. * <optional>
  16. *
  17. * Created:
  18. *
  19. * 08/30/2000 asecchia
  20. * Created it.
  21. *
  22. **************************************************************************/
  23. /**************************************************************************
  24. *
  25. * Function Description:
  26. *
  27. * <Description of what the function does>
  28. *
  29. * Arguments:
  30. *
  31. * [<blank> | OUT | IN/OUT] argument-name - description of argument
  32. * ......
  33. *
  34. * Return Value:
  35. *
  36. * return-value - description of return value
  37. * or NONE
  38. *
  39. * Created:
  40. *
  41. * 08/30/2000 asecchia
  42. * Created it.
  43. *
  44. **************************************************************************/
  45. #include "CPathGradient.hpp"
  46. #ifndef M_PI
  47. #define M_PI 3.1415926536
  48. #endif
  49. CPathGradient::CPathGradient(BOOL bRegression)
  50. {
  51. strcpy(m_szName,"Gradient : Path");
  52. m_bRegression=bRegression;
  53. }
  54. void CPathGradient::Draw(Graphics *g)
  55. {
  56. PointF points[7];
  57. points[0].X = 0.0f;
  58. points[0].Y = 0.0f;
  59. points[1].X = TESTAREAWIDTH;
  60. points[1].Y = 0.0f;
  61. points[2].X = TESTAREAWIDTH;
  62. points[2].Y = TESTAREAHEIGHT;
  63. points[3].X = 0.0f;
  64. points[3].Y = TESTAREAHEIGHT;
  65. points[4].X = 50.0f;
  66. points[4].Y = 100.0f;
  67. points[5].X = -1.00;
  68. points[5].Y = -1.00;
  69. points[6].X = 0;
  70. points[6].Y = 0;
  71. Color colors[6];
  72. colors[0] = Color(0xff000000);
  73. colors[1] = Color(0xffff0000);
  74. colors[2] = Color(0xff00ff00);
  75. colors[3] = Color(0xffff00ff);
  76. colors[4] = Color(0xffffff00);
  77. colors[5] = Color(0xff00ffff);
  78. float blend[6] = {0.0f, 0.1f, 0.3f, 0.5f, 0.7f, 1.0f};
  79. Pen pen(Color(0xff000000), 10.0f);
  80. GraphicsPath gp;
  81. gp.AddPolygon(points, 4);
  82. PathGradientBrush brush(points, 4);
  83. brush.SetCenterPoint(points[4]);
  84. brush.SetCenterColor(Color(0xff0000ff));
  85. Status status;
  86. INT count = 4;
  87. status = brush.SetSurroundColors(colors, &count);
  88. status = brush.SetInterpolationColors(colors, blend, 6);
  89. status = g->FillPath(&brush, &gp);
  90. }
  91. CPathGradient2::CPathGradient2(BOOL bRegression)
  92. {
  93. strcpy(m_szName,"Gradient : Path, 1D, Gamma Corrected");
  94. m_bRegression=bRegression;
  95. }
  96. void CPathGradient2::Draw(Graphics *g)
  97. {
  98. PointF points[7];
  99. points[0].X = 0.0f;
  100. points[0].Y = 0.0f;
  101. points[1].X = TESTAREAWIDTH;
  102. points[1].Y = 0.0f;
  103. points[2].X = TESTAREAWIDTH;
  104. points[2].Y = TESTAREAHEIGHT;
  105. points[3].X = 0.0f;
  106. points[3].Y = TESTAREAHEIGHT;
  107. points[4].X = 50.0f;
  108. points[4].Y = 100.0f;
  109. points[5].X = -1.00;
  110. points[5].Y = -1.00;
  111. points[6].X = 0;
  112. points[6].Y = 0;
  113. Color colors[6];
  114. colors[0] = Color(0xff0000ff);
  115. colors[1] = Color(0xff0000ff);
  116. colors[2] = Color(0xff0000ff);
  117. colors[3] = Color(0xff0000ff);
  118. colors[4] = Color(0xffffff00);
  119. colors[5] = Color(0xff00ffff);
  120. GraphicsPath gp;
  121. gp.AddPolygon(points, 4);
  122. PathGradientBrush brush(points, 4);
  123. brush.SetCenterPoint(points[4]);
  124. brush.SetCenterColor(Color(0x3f00ff00));
  125. Status status;
  126. INT count = 4;
  127. status = brush.SetSurroundColors(colors, &count);
  128. status = g->FillPath(&brush, &gp);
  129. }
  130. CPathGradient3::CPathGradient3(BOOL bRegression)
  131. {
  132. strcpy(m_szName,"Gradient : Path, Gamma Corrected");
  133. m_bRegression=bRegression;
  134. }
  135. void CPathGradient3::Draw(Graphics *g)
  136. {
  137. // width and height of our test rectangle.
  138. float width = TESTAREAWIDTH;
  139. float height = TESTAREAHEIGHT;
  140. // center point.
  141. float cx = width/2.0f;
  142. float cy = height/2.0f;
  143. PointF *points = new PointF[100];
  144. Color *colors = new Color[100];
  145. // Create the path and some random list of repeating colors.
  146. for(INT i=0;i<100;i++)
  147. {
  148. float angle = ((2.0f*(float)M_PI)*i)/100.0f;
  149. points[i].X = cx*(1.0f + (float)cos(angle));
  150. points[i].Y = cy*(1.0f + (float)sin(angle));
  151. colors[i] = Color(
  152. (i%10>0)?0xff:0x3f,
  153. (i%4>0)?0xff:0x00,
  154. (i%4==1)?0xff:0x3f,
  155. (i%6==2)?0xff:0x00
  156. );
  157. }
  158. // make the path.
  159. GraphicsPath gp;
  160. gp.AddPolygon(points, 100);
  161. // make the brush.
  162. INT count = 100;
  163. PathGradientBrush brush(points, 100);
  164. brush.SetCenterPoint(PointF(cx, cy));
  165. brush.SetCenterColor(Color(0x00000000));
  166. brush.SetSurroundColors(colors, &count);
  167. // Fill it.
  168. g->FillPath(&brush, &gp);
  169. }
  170. CLinearGradient::CLinearGradient(BOOL bRegression)
  171. {
  172. strcpy(m_szName,"Gradient : Linear");
  173. m_bRegression=bRegression;
  174. }
  175. void CLinearGradient::Draw(Graphics *g)
  176. {
  177. PointF points[4];
  178. points[0].X = 0.0f;
  179. points[0].Y = 0.0f;
  180. points[1].X = TESTAREAWIDTH;
  181. points[1].Y = 0.0f;
  182. points[2].X = TESTAREAWIDTH;
  183. points[2].Y = TESTAREAHEIGHT;
  184. points[3].X = 0.0f;
  185. points[3].Y = TESTAREAHEIGHT;
  186. GraphicsPath gp;
  187. gp.AddPolygon(points, 4);
  188. LinearGradientBrush brush(
  189. PointF(0.0f, 0.0f),
  190. PointF(TESTAREAWIDTH, TESTAREAHEIGHT),
  191. Color(0xffff0000),
  192. Color(0xff0000ff)
  193. );
  194. brush.SetGammaCorrection(FALSE);
  195. Status status = g->FillPath(&brush, &gp);
  196. }
  197. CLinearGradient2::CLinearGradient2(BOOL bRegression)
  198. {
  199. strcpy(m_szName,"Gradient : Linear, Gamma Corrected");
  200. m_bRegression=bRegression;
  201. }
  202. void CLinearGradient2::Draw(Graphics *g)
  203. {
  204. PointF points[4];
  205. points[0].X = 0.0f;
  206. points[0].Y = 0.0f;
  207. points[1].X = TESTAREAWIDTH;
  208. points[1].Y = 0.0f;
  209. points[2].X = TESTAREAWIDTH;
  210. points[2].Y = TESTAREAHEIGHT;
  211. points[3].X = 0.0f;
  212. points[3].Y = TESTAREAHEIGHT;
  213. GraphicsPath gp;
  214. gp.AddPolygon(points, 4);
  215. LinearGradientBrush brush(
  216. PointF(0.0f, 0.0f),
  217. PointF(TESTAREAWIDTH, TESTAREAHEIGHT),
  218. Color(0xffff0000),
  219. Color(0xff0000ff)
  220. );
  221. brush.SetGammaCorrection(TRUE);
  222. Status status = g->FillPath(&brush, &gp);
  223. }