namespace DDW
 {      
    public enum Pics : int {Box, Lines, Gradient, Array, Jagged};
    public class Draw
    {       
        public static string SFld= "static field";
        public string Fld = "field";
        public static void Main()
        {   
            Swf.WriteLine("===    C# --> Swf    ===");      
            Swf.WriteLine("Main Method");
            Draw d1 = new Draw("Hello");
            Swf.WriteLine("App width: " + d1.Width + "  App height: " + d1.Height);
            SFld = "mod static field XXX";
            Draw d2 = new Draw(2.5F);
            long lg = 25;
            Draw d2L = new Draw(lg);
            Draw d3 = new Draw(Pics.Gradient);
            Draw d4 = new Draw(Pics.Box);
            Draw d5 = new Draw(Pics.Lines);
            Draw d6 = new Draw(Pics.Array);
            Draw d7 = new Draw(Pics.Jagged);
            Swf.WriteLine("End Program");
        }
        public Draw(string msg)
        {
            Swf.WriteLine("Draw constructor (string overload) msg: " + msg);
            Swf.WriteLine("static: " + SFld + "  norm: " + Fld);
            Fld = "change here";
        }
        public Draw(float f)
        {
            Swf.WriteLine("Draw constructor (float overload) #: " + f);
        }
        public Draw(long lg)
        {
            Swf.WriteLine("Draw constructor (long overload) #: " + lg);
            Swf.WriteLine("static: " + SFld + "  norm: " + Fld);
        }
        public Draw(Pics drawing)
        {
            Swf.WriteLine("Draw constructor ('Pics' overload) : "+drawing);
            switch(drawing)
            {
                case Pics.Gradient:
                {
                    DrawingGradient();
                    break;
                }
                case Pics.Box:
                {
                    DrawingBox();
                    break;
                }
                case Pics.Lines:
                {
                    DrawingLines();
                    break;
                }
                case Pics.Array:
                {
                    DrawingArray(400, 450);
                    break;
                }
                case Pics.Jagged:
                {
                    DrawingJaggedArray(400, 550);
                    break;
                }
                default:
                {
                    DrawingLines();
                    break;
                }
            }
        }
        
        public int m_width = 550;
        public int Width
        {
            get
            {
                Swf.WriteLine("Width ***");
                return m_width;
            }
            set
            {
                m_width = value;
            }
        }
        public int m_height = 600;
        public int Height
        {
            get
            {
                return m_height;
            }
            set
            {
                m_height = value;
            }
        }
        
        public void Circle(int radius, int x, int y)
        {
            //Swf.WriteLine("Circle Method (r,x,y overload)");
            int top = y - radius;
            int left = x - radius;
            int width = radius * 2;
            int height = radius * 2;
            Circle(top, left, width, height);
        }
        public void Circle(int top, int left, int width, int height)
        {
            //Swf.WriteLine("Circle Method  -- t :"+top+" l:" + left + " w:" + width + " h:" + height);
            float min = .0F;
            float max = 1F;
            int ctop = (int)(top  + height*min);
            int clef = (int)(left + width *min);
            int cbot = (int)(top  + height*max);
            int crig = (int)(left + width*max);
            
            Swf.MoveTo(left+width/2, top);
            Swf.CurveTo(crig, ctop,     left+width,top+height/2);
            Swf.CurveTo(crig, cbot,     left+width/2,top+height);
            Swf.CurveTo(clef, cbot,     left,top+height/2);
            Swf.CurveTo(clef, ctop,     left+width/2,top);
        }       
        public void Rectangle(int top, int left, int width, int height)
        {   
            //Swf.WriteLine("Rectangle -- t:"+top+" l:" + left + " w:" + width + " h:" + height);   
            Swf.MoveTo(left, top);
            Swf.LineTo(left+width, top);
            Swf.LineTo(left+width, top+height);
            Swf.LineTo(left, top+height);
            Swf.LineTo(left, top);
        }       
        public void DrawingGradient()
        {
            Swf.WriteLine("Rendering Drawing1...");
            Swf.RemoveOutline();
            int y = 0;
            while(true)
            {
                Swf.BeginFill(y*2, 0, 0x50 - y);
                Rectangle(y*10,0, 550,10);
                Swf.EndFill();
                if(y++ > 60) break;
            }
        }   
        public void DrawingBox()
        {
            Swf.WriteLine("Rendering Drawing2...");
            Swf.LineStyle(2, 0, 0, 0);
            Swf.BeginFill(0xDD, 0xDD, 0xE0);
            Rectangle(300,350, 150,100);
            Swf.EndFill();
            
            Swf.BeginFill(0xFF, 0x00, 0x40);
            Circle(20, 350,300);
            Swf.EndFill();
            
            Swf.BeginFill(0xFF, 0x40 , 0x00);
            Circle(20, 500,300);
            Swf.EndFill();
            
            Swf.BeginFill( 0x40, 0xFF, 0x00);
            Circle(20, 500,400);
            Swf.EndFill();
            
            Swf.BeginFill(0x00, 0x9F, 0xC0);
            Circle(20, 350,400);
            Swf.EndFill();
            
        }           
        public void DrawingLines()
        {
            Swf.WriteLine("Rendering Drawing3...");
            for(int i = 0; i < 10; i++)
            {
                Swf.LineStyle(i, 200-1*5, 30, 255 - i*10);
                Swf.MoveTo(400, 50 + i * 20);
                Swf.LineTo(530, 100 + i * 10);
            }
        }       
        public void DrawingArray(int x, int y)
        {
            Swf.WriteLine("Rendering Drawing4...");
            Swf.LineStyle(2, 80,150,200);
            int ptCount = 7;
            int[] ptsx = new int[]{0,50,75,50,0,25,0};
            int[] ptsy = new int[]{0,0,25,50,50,25,0};
            
            Swf.MoveTo(ptsx[0] + x, ptsy[0] + y);
            Swf.BeginFill(0x00, 0x3F, 0xA0);
            for(int i = 1; i < ptCount; i++)
            {
                Swf.LineTo(ptsx[i] + x, ptsy[i] + y);
            }
            Swf.EndFill();
        }
        public void DrawingJaggedArray(int x, int y)
        {
            Swf.WriteLine("Rendering Drawing Jag...");
            Swf.LineStyle(2, 150,80,200);
            int ptCount = 9;
            int[,] pts = new int[,]
            {
            {0,-20},
            {5,-5},
            {20,0},
            {5,5},
            {0,20},
            {-5,5},
            {-20,0},
            {-5,-5},
            {0,-20}
            };
            
            Swf.MoveTo(pts[0,0] + x, pts[0,1] + y);
            Swf.BeginFill(0xD0, 0x60, 0x30);
            for(int i = 1; i < ptCount; i++)
            {
                Swf.LineTo(pts[i,0] + x, pts[i,1] + y);
            }
            Swf.EndFill();
        }
            
    }
    
    
    
    
        // stub class (these are just mapped internally for now)
        public class Swf
        {
            // drawing API
            public static void LineStyle(int width, int r, int g, int b){}
            public static void RemoveOutline(){}
            public static void BeginFill(int r, int g, int b){}
            public static void EndFill(){}
            public static void Clear(){}
            public static void MoveTo(int x, int y){}
            public static void LineTo(int x, int y){}
            public static void CurveTo(int cx, int cy, int ax, int ay){}
            
            // Console
            public static void Write(object s){}
            public static void WriteLine(object s){}
        }   
    
 }
 // bye