How to fill colors at circle?
Moderators: SDS, support, admin
How to fill colors at circle?
Hello,
I made a button for making a circle.
Let's see it below:
private void button1_Click(object sender, EventArgs e)
{
CreateNewDrawing();
CADCircle vCircle = new CADCircle();
vCircle.Color = Color.Red;
vCircle.Point = new DPoint(100, 100, 0);
vCircle.Radius = 0.1;
cadImage.Converter.Loads(vCircle);
cadImage.CurrentLayout.AddEntity(vCircle);
cadImage.GetExtents();
RectangleF vRect;
double vRatio = (double)(cadImage.AbsHeight * pictureBox1.ClientSize.Width) / (cadImage.AbsWidth * pictureBox1.ClientSize.Height);
if (vRatio > 1)
vRect = new RectangleF(0, 0, (float)(pictureBox1.ClientSize.Width / vRatio), (float)pictureBox1.ClientSize.Height);
else
vRect = new RectangleF(0, 0, (float)pictureBox1.ClientSize.Width, (float)(pictureBox1.ClientSize.Height * vRatio));
cadImage.Draw(pictureBox1.CreateGraphics(), vRect);
}
I could make a circle, but couldn't fill the color in the circle.
Do you have a way?
Thanks,
JH Yoon
I made a button for making a circle.
Let's see it below:
private void button1_Click(object sender, EventArgs e)
{
CreateNewDrawing();
CADCircle vCircle = new CADCircle();
vCircle.Color = Color.Red;
vCircle.Point = new DPoint(100, 100, 0);
vCircle.Radius = 0.1;
cadImage.Converter.Loads(vCircle);
cadImage.CurrentLayout.AddEntity(vCircle);
cadImage.GetExtents();
RectangleF vRect;
double vRatio = (double)(cadImage.AbsHeight * pictureBox1.ClientSize.Width) / (cadImage.AbsWidth * pictureBox1.ClientSize.Height);
if (vRatio > 1)
vRect = new RectangleF(0, 0, (float)(pictureBox1.ClientSize.Width / vRatio), (float)pictureBox1.ClientSize.Height);
else
vRect = new RectangleF(0, 0, (float)pictureBox1.ClientSize.Width, (float)(pictureBox1.ClientSize.Height * vRatio));
cadImage.Draw(pictureBox1.CreateGraphics(), vRect);
}
I could make a circle, but couldn't fill the color in the circle.
Do you have a way?
Thanks,
JH Yoon
Re: How to fill colors at circle?
Hello JH Yoon,
To fill a circle with color, you'll have to create a solid hatch with the boundary equal to the circle boundary. In other words, you will need to replicate the circle boundary using one of the CAD2DCurve derivatives, to be more exact, with using a CAD2DEllipse object:
Notice that the CAD2DCurve derivatives (CAD2DEllipse, CAD2DLine, CAD2DArc, etc.) are auxiliary objects, they are not added directly to CADImage.Converter and not visible on the drawing. These objects should be used to form a hatch boundary list:
Now you have a boundary list that consists of a single boundary which replicates the boundary of your circle, so you can create a solid hatch:
Mikhail
To fill a circle with color, you'll have to create a solid hatch with the boundary equal to the circle boundary. In other words, you will need to replicate the circle boundary using one of the CAD2DCurve derivatives, to be more exact, with using a CAD2DEllipse object:
Code: Select all
CADCircle vCircle = new CADCircle();
vCircle.Color = Color.Red;
vCircle.Point = new DPoint(100, 100, 0);
vCircle.Radius = 30;
cadImage.Converter.Loads(vCircle);
cadImage.CurrentLayout.AddEntity(vCircle);
CAD2DEllipse vEllipse = new CAD2DEllipse();
vEllipse.CenterPoint = vCircle.Point;
// The x-coordinate of the major point should be equal to the circle radius
vEllipse.MajorPoint = new CAD2DPoint(30, 0);
// Note: CAD2DEllipse.Radius actually specifies a ratio between the major and minor axes of CAD2DEllipse
vEllipse.Radius = 1;
Code: Select all
CAD2DBoundaryList vBoundaryList = new CAD2DBoundaryList();
vBoundaryList.Add(vEllipse);
Code: Select all
CADCurvePolygon vHatch = new CADCurvePolygon();
vHatch.BoundaryData.Add(vBoundaryList);
vHatch.Color = Color.Green;
cadImage.Converter.Loads(vHatch);
cadImage.CurrentLayout.AddEntity(vHatch);
cadImage.GetExtents();
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support