Csharp/C Sharp/2D Graphics/FillMode — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 11:42, 26 мая 2010

Alternate

 
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
class FillModesOddity : Form {
    public static void Main() {
        Application.Run(new FillModesOddity());
    }
    public FillModesOddity() {
        Text = "Alternate and Winding Fill Modes (An Oddity)";
        ClientSize = new Size(2 * ClientSize.Height, ClientSize.Height);
        ResizeRedraw = true;
    }
    protected override void OnPaint(PaintEventArgs pea) {
        DoPage(pea.Graphics, ForeColor, ClientSize.Width, ClientSize.Height);
    }
    protected void DoPage(Graphics grfx, Color clr, int cx, int cy) {
        Brush brush = new SolidBrush(clr);
        PointF[] aptf = { new PointF(100.1f, 400.7f), new PointF(400.5f, 10.7f),
                            new PointF(200.5f, 300.1f), new PointF(300.9f, 20.1f),
                            new PointF(300.9f, 200.5f), new PointF(300.3f, 390.5f),
                            new PointF(400.3f, 0.9f), new PointF(200.7f, 200.9f),
                            new PointF(500.7f, 100.3f), new PointF(100.1f, 400.3f)};
        grfx.FillPolygon(brush, aptf, FillMode.Alternate);
    }
}


Winding

 

using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
   
class FillModesOddity: Form
{
     public static void Main()
     {
          Application.Run(new FillModesOddity());
     }
     public FillModesOddity()
     {
          Text = "Alternate and Winding Fill Modes (An Oddity)";
          ClientSize = new Size(2 * ClientSize.Height, ClientSize.Height);
          ResizeRedraw = true;
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }     
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          Brush    brush = new SolidBrush(clr);
          PointF[] aptf = { new PointF(100.1f, 400.7f), new PointF(400.5f, 10.7f),
                            new PointF(200.5f, 300.1f), new PointF(300.9f, 20.1f),
                            new PointF(300.9f, 200.5f), new PointF(300.3f, 390.5f),
                            new PointF(400.3f, 0.9f), new PointF(200.7f, 200.9f),
                            new PointF(500.7f, 100.3f), new PointF(100.1f, 400.3f)};
          
          grfx.FillPolygon(brush, aptf, FillMode.Winding);
     }
}