pie.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // Test application for pie graphics functions implementation
  3. //
  4. // Author:
  5. // Jordi Mas, [email protected]
  6. //
  7. //
  8. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Drawing.Imaging;
  31. using System.Drawing;
  32. using System.Drawing.Drawing2D;
  33. //
  34. public class graphicsUI
  35. {
  36. public static void Main ()
  37. {
  38. Bitmap bmp = new Bitmap (400, 600);
  39. Graphics dc = Graphics.FromImage (bmp);
  40. // Clears and set the background color to red
  41. dc.Clear (Color.Red);
  42. SolidBrush blueBrush = new SolidBrush (Color.Blue);
  43. SolidBrush redBrush = new SolidBrush (Color.Red);
  44. SolidBrush yellowBrush = new SolidBrush (Color.Yellow);
  45. SolidBrush whiteBrush = new SolidBrush (Color.White);
  46. Pen bluePen = new Pen (Color.Blue);
  47. // We have a column starting at x=50 for Draw operations
  48. // and another column starting at x=200 for Fill operations.
  49. // Both the columns grow downwards.
  50. // Column 1
  51. Rectangle rect11 = new Rectangle (50, 0, 75, 75);
  52. dc.DrawPie (bluePen, rect11, 10, 60);
  53. Rectangle rect12 = new Rectangle (50,100, 75, 75);
  54. dc.DrawPie (bluePen, rect12, 100, 75);
  55. Rectangle rect13 = new Rectangle (50, 200, 75, 75);
  56. dc.DrawPie (bluePen, rect13, 100, 400);
  57. Rectangle rect14 = new Rectangle (50, 300, 75, 75);
  58. dc.DrawPie (bluePen, rect14, 0, 0);
  59. // Column 2
  60. Rectangle rect21 = new Rectangle (200, 0, 75, 75);
  61. dc.FillPie (yellowBrush, rect21, 0, 300);
  62. Rectangle rect22 = new Rectangle (200, 100, 75, 75);
  63. dc.FillPie (whiteBrush, rect22, 200, 30);
  64. Rectangle rect23 = new Rectangle (200, 200, 75, 75);
  65. dc.FillPie (whiteBrush, rect23, 200, 400);
  66. Rectangle rect24 = new Rectangle (200, 300, 75, 75);
  67. dc.FillPie (yellowBrush, rect24, 190, 300);
  68. Rectangle rect25 = new Rectangle (200, 400, 75, 75);
  69. dc.FillPie (whiteBrush, rect25, 200, 20);
  70. Rectangle rect26 = new Rectangle (200, 500, 75, 75);
  71. dc.FillPie (yellowBrush, rect26, 50, 0);
  72. bmp.Save("fillpie.png", ImageFormat.Png);
  73. }
  74. }