improved the bezier generator
This commit is contained in:
@@ -84,13 +84,51 @@ namespace Paint_2
|
||||
{
|
||||
for (int i = 0; i < points.Count; i++)
|
||||
{
|
||||
pointSize = new Size(Widths[0]/2, Widths[0]/2);
|
||||
gr.FillEllipse(new SolidBrush(Colors[i]), new Rectangle(new Point(points[i].X - pointSize.Width / 2, points[i].Y - pointSize.Height / 2), pointSize));
|
||||
ContinuousBezierGenerator(gr, points, Colors[Colors.Count-1], Widths[Widths.Count -1]);
|
||||
pointSize = new Size(Widths[0] / 2, Widths[0] / 2);
|
||||
//ContinuousBezierGenerator(gr, points, Colors[Colors.Count-1], Widths[Widths.Count -1]);
|
||||
AdjustedBezierGenerator(gr, points, Colors[Colors.Count - 1], Widths[Widths.Count - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ContinuousBezierGenerator(Graphics gr, List<Point> points,Color color,int width)
|
||||
private void AdjustedBezierGenerator(Graphics gr, List<Point> points, Color color, int width)
|
||||
{
|
||||
/*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;
|
||||
for (float t = 0; t <= 1; t += precision)
|
||||
{
|
||||
List<Point> DumpList = new List<Point>();
|
||||
List<Point> WorkingList = new List<Point>();
|
||||
|
||||
foreach (Point p in points)
|
||||
{
|
||||
WorkingList.Add(new Point(p.X, p.Y));
|
||||
}
|
||||
while (WorkingList.Count > 1)
|
||||
{
|
||||
for (int i = 0; i < WorkingList.Count - 1; i++)
|
||||
{
|
||||
Point p1 = WorkingList[i];
|
||||
Point p2 = WorkingList[i + 1];
|
||||
Point tmp = Utils.Lerp(p1, p2, t);
|
||||
DumpList.Add(tmp);
|
||||
}
|
||||
WorkingList.Clear();
|
||||
foreach (Point p in DumpList)
|
||||
{
|
||||
WorkingList.Add(new Point(p.X, p.Y));
|
||||
}
|
||||
DumpList.Clear();
|
||||
}
|
||||
gr.FillEllipse(new SolidBrush(color), new Rectangle(WorkingList[0].X - Widths[0] / 2, WorkingList[0].Y - Widths[0] / 2, width, width));
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ContinuousBezierGenerator(Graphics gr, List<Point> points, Color color, int width)
|
||||
{
|
||||
if (points.Count >= 4 && points.Count % 2 == 0)
|
||||
{
|
||||
@@ -215,7 +253,7 @@ namespace Paint_2
|
||||
}
|
||||
public void Start(Color color, int width)
|
||||
{
|
||||
Utils.StandartStart(color,width);
|
||||
Utils.StandartStart(color, width);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
|
||||
32
Paint_2/Form1.Designer.cs
generated
32
Paint_2/Form1.Designer.cs
generated
@@ -94,7 +94,7 @@
|
||||
this.tbxProjectName.Location = new System.Drawing.Point(2, 4);
|
||||
this.tbxProjectName.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.tbxProjectName.Name = "tbxProjectName";
|
||||
this.tbxProjectName.Size = new System.Drawing.Size(225, 38);
|
||||
this.tbxProjectName.Size = new System.Drawing.Size(225, 32);
|
||||
this.tbxProjectName.TabIndex = 0;
|
||||
this.tbxProjectName.Text = "Untitled Project";
|
||||
//
|
||||
@@ -145,7 +145,7 @@
|
||||
this.lblSelectedColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.lblSelectedColor.Location = new System.Drawing.Point(6, 23);
|
||||
this.lblSelectedColor.Name = "lblSelectedColor";
|
||||
this.lblSelectedColor.Size = new System.Drawing.Size(256, 18);
|
||||
this.lblSelectedColor.Size = new System.Drawing.Size(202, 14);
|
||||
this.lblSelectedColor.TabIndex = 1;
|
||||
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||
//
|
||||
@@ -193,7 +193,7 @@
|
||||
this.lblHeight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.lblHeight.Location = new System.Drawing.Point(3, 38);
|
||||
this.lblHeight.Name = "lblHeight";
|
||||
this.lblHeight.Size = new System.Drawing.Size(66, 18);
|
||||
this.lblHeight.Size = new System.Drawing.Size(53, 14);
|
||||
this.lblHeight.TabIndex = 34;
|
||||
this.lblHeight.Text = "H:2000";
|
||||
//
|
||||
@@ -203,7 +203,7 @@
|
||||
this.lblWidth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.lblWidth.Location = new System.Drawing.Point(3, 7);
|
||||
this.lblWidth.Name = "lblWidth";
|
||||
this.lblWidth.Size = new System.Drawing.Size(69, 18);
|
||||
this.lblWidth.Size = new System.Drawing.Size(57, 14);
|
||||
this.lblWidth.TabIndex = 33;
|
||||
this.lblWidth.Text = "W:2000";
|
||||
//
|
||||
@@ -239,7 +239,7 @@
|
||||
this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.label14.Location = new System.Drawing.Point(6, 5);
|
||||
this.label14.Name = "label14";
|
||||
this.label14.Size = new System.Drawing.Size(150, 22);
|
||||
this.label14.Size = new System.Drawing.Size(120, 18);
|
||||
this.label14.TabIndex = 29;
|
||||
this.label14.Text = "Selected color";
|
||||
//
|
||||
@@ -274,7 +274,7 @@
|
||||
this.lblHoveringColor.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.lblHoveringColor.Location = new System.Drawing.Point(7, 23);
|
||||
this.lblHoveringColor.Name = "lblHoveringColor";
|
||||
this.lblHoveringColor.Size = new System.Drawing.Size(256, 18);
|
||||
this.lblHoveringColor.Size = new System.Drawing.Size(202, 14);
|
||||
this.lblHoveringColor.TabIndex = 1;
|
||||
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||
//
|
||||
@@ -285,7 +285,7 @@
|
||||
this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.label15.Location = new System.Drawing.Point(7, 5);
|
||||
this.label15.Name = "label15";
|
||||
this.label15.Size = new System.Drawing.Size(150, 22);
|
||||
this.label15.Size = new System.Drawing.Size(120, 18);
|
||||
this.label15.TabIndex = 29;
|
||||
this.label15.Text = "Hovering color";
|
||||
//
|
||||
@@ -308,7 +308,7 @@
|
||||
0,
|
||||
0});
|
||||
this.nupPencilWidth.Name = "nupPencilWidth";
|
||||
this.nupPencilWidth.Size = new System.Drawing.Size(55, 33);
|
||||
this.nupPencilWidth.Size = new System.Drawing.Size(55, 27);
|
||||
this.nupPencilWidth.TabIndex = 17;
|
||||
this.nupPencilWidth.Value = new decimal(new int[] {
|
||||
10,
|
||||
@@ -409,7 +409,7 @@
|
||||
this.lsbTools.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.lsbTools.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.lsbTools.FormattingEnabled = true;
|
||||
this.lsbTools.ItemHeight = 18;
|
||||
this.lsbTools.ItemHeight = 14;
|
||||
this.lsbTools.Location = new System.Drawing.Point(6, 20);
|
||||
this.lsbTools.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.lsbTools.Name = "lsbTools";
|
||||
@@ -433,7 +433,7 @@
|
||||
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.label1.Location = new System.Drawing.Point(3, 2);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(108, 20);
|
||||
this.label1.Size = new System.Drawing.Size(84, 16);
|
||||
this.label1.TabIndex = 36;
|
||||
this.label1.Text = "Paint tools";
|
||||
//
|
||||
@@ -547,7 +547,7 @@
|
||||
this.label3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.label3.Location = new System.Drawing.Point(3, 8);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(63, 20);
|
||||
this.label3.Size = new System.Drawing.Size(49, 16);
|
||||
this.label3.TabIndex = 37;
|
||||
this.label3.Text = "Layers";
|
||||
//
|
||||
@@ -597,7 +597,7 @@
|
||||
this.label2.Font = new System.Drawing.Font("Cascadia Code", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label2.Location = new System.Drawing.Point(7, 8);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(0, 20);
|
||||
this.label2.Size = new System.Drawing.Size(0, 16);
|
||||
this.label2.TabIndex = 36;
|
||||
//
|
||||
// DebugLabel
|
||||
@@ -605,7 +605,7 @@
|
||||
this.DebugLabel.AutoSize = true;
|
||||
this.DebugLabel.Location = new System.Drawing.Point(18, 86);
|
||||
this.DebugLabel.Name = "DebugLabel";
|
||||
this.DebugLabel.Size = new System.Drawing.Size(55, 18);
|
||||
this.DebugLabel.Size = new System.Drawing.Size(48, 14);
|
||||
this.DebugLabel.TabIndex = 38;
|
||||
this.DebugLabel.Text = "Debug";
|
||||
//
|
||||
@@ -631,10 +631,10 @@
|
||||
this.btnSvgExport.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
|
||||
this.btnSvgExport.Font = new System.Drawing.Font("Cascadia Code", 10.2F);
|
||||
this.btnSvgExport.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.btnSvgExport.Location = new System.Drawing.Point(1039, 545);
|
||||
this.btnSvgExport.Location = new System.Drawing.Point(1014, 505);
|
||||
this.btnSvgExport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.btnSvgExport.Name = "btnSvgExport";
|
||||
this.btnSvgExport.Size = new System.Drawing.Size(150, 33);
|
||||
this.btnSvgExport.Size = new System.Drawing.Size(196, 33);
|
||||
this.btnSvgExport.TabIndex = 37;
|
||||
this.btnSvgExport.Text = "Export SVG";
|
||||
this.btnSvgExport.UseVisualStyleBackColor = false;
|
||||
@@ -642,7 +642,7 @@
|
||||
//
|
||||
// PaintForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 14F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(34)))), ((int)(((byte)(34)))));
|
||||
this.ClientSize = new System.Drawing.Size(1222, 618);
|
||||
|
||||
Reference in New Issue
Block a user