ChangeLog: Updated ChangeLog.
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / hering.cs
1 //
2 // hering.cs 
3 // Creates image for Hering illusion.
4 // Converted to C# from Xr demo application.
5 //
6 // Author:
7 //   Alexandre Pigolkine(pigolkine@gmx.de)
8 // 
9 //
10 // (C) Ximian, Inc.  http://www.ximian.com
11 //
12
13 using System;
14 using System.Drawing;
15 using System.Drawing.Imaging;
16 using System.Drawing.Drawing2D;
17  
18 namespace xrtest {
19  public class xrt {
20   public static void Main( String[] arr) {
21    float width = 400.0F;
22    float height = 800.0F;
23    
24    Bitmap bmp = new Bitmap((int)width, (int)height/*, PixelFormat.Format24bppRgb*/);
25    Graphics gr = Graphics.FromImage(bmp);
26    SolidBrush br = new SolidBrush(Color.White);
27    gr.FillRectangle(br, 0.0F, 0.0F, width, height);
28
29    int LINES = 32;
30    float MAX_THETA  = (.80F * 90.0F);
31    float THETA  = (2 * MAX_THETA / (LINES-1));
32    
33    Pen blackPen = new Pen(Color.Black, 2.0F);
34    GraphicsState state   = gr.Save();
35  
36    gr.TranslateTransform(width/2.0F, height/2.0F);
37    gr.RotateTransform(MAX_THETA);
38    for( int i = 0; i < LINES; i++) {
39     gr.DrawLine( blackPen, -2.0F * width, 0.0F, 2.0F * width, 0.0F);
40     gr.RotateTransform(-THETA);
41    }
42    gr.Restore(state);
43    
44    Pen redPen = new Pen(Color.Red, 6F);
45    gr.DrawLine( redPen, width / 4F, 0F, width / 4F, height);
46    gr.DrawLine( redPen, 3F * width / 4F, 0F, 3F * width / 4F, height);
47    
48    bmp.Save("Hering.bmp", ImageFormat.Bmp);
49    Console.WriteLine("output file Hering.bmp");
50    bmp.Save("Hering.jpg", ImageFormat.Jpeg);
51    Console.WriteLine("output file Hering.jpg");
52   /*
53    bmp.Save("Hering.png", ImageFormat.Png);
54    Console.WriteLine("output file Hering.png");
55   */
56   }
57  }
58 }