Fixed the SVG generator of the bezier pencil
This commit is contained in:
@@ -96,10 +96,10 @@ namespace Paint_2
|
||||
}
|
||||
private void AdjustedBezierGenerator(Graphics gr, List<Point> points, Color color, int width)
|
||||
{
|
||||
/*foreach (Point p in points)
|
||||
foreach (Point p in points)
|
||||
{
|
||||
gr.FillEllipse(new SolidBrush(color), new Rectangle(new Point(p.X - width / 2, p.Y - width / 2), new Size(width,width)));
|
||||
}*/
|
||||
}
|
||||
if (points.Count >= 3)
|
||||
{
|
||||
float precision = 0.01f;
|
||||
@@ -194,33 +194,36 @@ namespace Paint_2
|
||||
string result = "";
|
||||
string newLine = Environment.NewLine;
|
||||
|
||||
if (points.Count >= 4 && points.Count % 2 == 0)
|
||||
if (points.Count >= 3)
|
||||
{
|
||||
float precision = 0.01f;
|
||||
for (float t = 0; t <= 1; t += precision)
|
||||
{
|
||||
List<Point> DumpList = new List<Point>();
|
||||
List<Point> WorkingList = new List<Point>(points);
|
||||
List<Point> WorkingList = new List<Point>();
|
||||
|
||||
while (WorkingList.Count != 1)
|
||||
foreach (Point p in points)
|
||||
{
|
||||
if (WorkingList.Count > 1)
|
||||
WorkingList.Add(new Point(p.X, p.Y));
|
||||
}
|
||||
while (WorkingList.Count > 1)
|
||||
{
|
||||
for (int i = 0; i < WorkingList.Count - 1; i++)
|
||||
{
|
||||
for (int pos = 0; pos < WorkingList.Count - 1; pos++)
|
||||
{
|
||||
DumpList.Add(Utils.Lerp(WorkingList[pos], WorkingList[pos + 1], t));
|
||||
}
|
||||
Point p1 = WorkingList[i];
|
||||
Point p2 = WorkingList[i + 1];
|
||||
Point tmp = Utils.Lerp(p1, p2, t);
|
||||
DumpList.Add(tmp);
|
||||
}
|
||||
else
|
||||
WorkingList.Clear();
|
||||
foreach (Point p in DumpList)
|
||||
{
|
||||
DumpList.Add(Utils.Lerp(WorkingList[0], WorkingList[1], precision));
|
||||
WorkingList.Add(new Point(p.X, p.Y));
|
||||
}
|
||||
WorkingList = new List<Point>(DumpList);
|
||||
DumpList = new List<Point>();
|
||||
DumpList.Clear();
|
||||
}
|
||||
result += "<ellipse cx=\"" + WorkingList[0].X + "\" cy=\"" + WorkingList[0].Y + "\" rx=\"" + width / 2 + "\" ry=\"" + width / 2 + "\" style=\"fill:rgb(" + color.R + ", " + color.G + ", " + color.B + ");\"/>";
|
||||
result += newLine;
|
||||
//gr.FillEllipse(new SolidBrush(color), new Rectangle(WorkingList[0].X - Widths[0] / 2, WorkingList[0].Y - Widths[0] / 2, width, width));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user