// FlyingArrowApplication.cs (c) Kari Laitinen // http://www.naturalprogramming.com/ // 2008-02-22 File created. // 2022-12-20 Tested in Developer Command Prompt for VS 2022. // This is a C# application that demonstrates // - the use of the GraphicsPath class // - transformations of the graphical coordinate system using System ; using System.Windows.Forms ; using System.Drawing ; using System.Drawing.Drawing2D ; class FlyingArrowForm : Form { public FlyingArrowForm() { Text = "DEMONSTRATING 2D GRAPHICS" ; // Setting window title. Size = new Size( 800, 500 ) ; // Size of the window. } protected override void OnPaint( PaintEventArgs paint_data ) { Graphics graphics = paint_data.Graphics ; // The arrow coordinates are selected so that Point (0, 0) // is at the tip of the arrow, and the arrow points upwards. Point[] arrow_shape_coordinates = { new Point( 0, 0 ), new Point( 15, 40 ), new Point( 5, 30 ), new Point( 5, 120 ), new Point( 15, 160 ), new Point( 0, 130 ), new Point( -15, 160 ), new Point( -5, 120 ), new Point( -5, 30 ), new Point( -15, 40 ) } ; GraphicsPath flying_arrow = new GraphicsPath() ; flying_arrow.StartFigure() ; flying_arrow.AddLines( arrow_shape_coordinates ) ; flying_arrow.CloseFigure() ; Brush black_brush = new SolidBrush( Color.Black ) ; Pen black_pen = new Pen( Color.Black ) ; graphics.TranslateTransform( 150, 250 ) ; // arrow tip to ( 150, 250 ) graphics.FillPath( black_brush, flying_arrow ) ; // draw solid arrow graphics.RotateTransform( 45 ) ; // 45 degrees clockwise graphics.DrawPath( black_pen, flying_arrow ) ; // draw a hollow arrow graphics.TranslateTransform( 0, -200 ) ; // flying "up" 200 points graphics.FillPath( black_brush, flying_arrow ) ; graphics.RotateTransform( 45 ) ; // 45 degrees clockwise graphics.TranslateTransform( 0, -200 ) ; // flying "up" (right) graphics.FillPath( black_brush, flying_arrow ) ; graphics.TranslateTransform( 0, -100 ) ; // flying "up" 100 points graphics.RotateTransform( 90 ) ; // 90 degrees clockwise graphics.ScaleTransform( 1.5F, 1.5F ) ; // magnify everything by 1.5 graphics.DrawPath( black_pen, flying_arrow ) ; // "up" means now down graphics.TranslateTransform( 0, -200 ) ; // flying "up" 300 points graphics.FillPath( black_brush, flying_arrow ) ; } } class FlyingArrowApplication { static void Main() { Application.Run( new FlyingArrowForm() ) ; } }