Graphics.FillPath( Brush, GraphicsPath ) does not fill a simple Path.
-
I think this problem occurs because of x and y of points because when I change the points, the shape will fill correctly. Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;namespace FillTriangle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void Form1\_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; GraphicsPath gp = new GraphicsPath(FillMode.Winding); gp.AddLine(new PointF(290, 170),new PointF(98, 128)); gp.AddLine(new PointF(110, 170), new PointF(290, 170)); gp.AddLine(new PointF(110, 170), new PointF(98, 128)); g.FillPath(new SolidBrush(Color.Red), gp); } }
}
-
I think this problem occurs because of x and y of points because when I change the points, the shape will fill correctly. Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;namespace FillTriangle
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void Form1\_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; GraphicsPath gp = new GraphicsPath(FillMode.Winding); gp.AddLine(new PointF(290, 170),new PointF(98, 128)); gp.AddLine(new PointF(110, 170), new PointF(290, 170)); gp.AddLine(new PointF(110, 170), new PointF(98, 128)); g.FillPath(new SolidBrush(Color.Red), gp); } }
}
WDI wrote:
I think this problem occurs because of x and y of points because when I change the points, the shape will fill
Of-course the problem is occurring because of co-ordinates x and y. :)
modified on Tuesday, December 21, 2010 12:08 AM