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