Added painting in SVG (ONLY FOR THE PENCIL AND DOT PENCIL FOR)
This commit is contained in:
@@ -182,5 +182,10 @@ namespace Paint_2
|
||||
result.Color = Color;
|
||||
return (Object)(result);
|
||||
}
|
||||
|
||||
public string PaintSVG()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,5 +138,34 @@ namespace Paint_2
|
||||
result.Color = Color;
|
||||
return (Object)(result);
|
||||
}
|
||||
|
||||
public string PaintSVG()
|
||||
{
|
||||
string result = "";
|
||||
string newLine = Environment.NewLine;
|
||||
|
||||
for (int drawCount = 0; drawCount < Drawings.Count; drawCount++)
|
||||
{
|
||||
Point p1;
|
||||
Point p2;
|
||||
List<Point> drawing = Drawings[drawCount];
|
||||
Color color = Colors[drawCount];
|
||||
int width = Widths[drawCount];
|
||||
for (int pointIndex = 0; pointIndex < drawing.Count; pointIndex++)
|
||||
{
|
||||
if (pointIndex >= 1)
|
||||
{
|
||||
p1 = drawing[pointIndex - 1];
|
||||
p2 = drawing[pointIndex];
|
||||
|
||||
result += "<ellipse cx=\"" + p2.X + "\" cy=\"" + p2.Y + "\" rx=\"" + width / 2 + "\" ry=\"" + width / 2 + "\" style=\"fill:rgb(" + color.R + ", " + color.G + ", " + color.B + ");\"/>";
|
||||
result += newLine;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ namespace Paint_2
|
||||
{
|
||||
Graphics gr = Graphics.FromImage(canvas);
|
||||
int drawingCounter = 0;
|
||||
Size pointSize;
|
||||
|
||||
foreach (List<Point> drawing in Drawings)
|
||||
{
|
||||
if (drawing.Count == 2)
|
||||
@@ -150,5 +148,10 @@ namespace Paint_2
|
||||
result.Color = Color;
|
||||
return (Object)(result);
|
||||
}
|
||||
|
||||
public string PaintSVG()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,5 +149,10 @@ namespace Paint_2
|
||||
result.Color = Color;
|
||||
return (Object)(result);
|
||||
}
|
||||
|
||||
public string PaintSVG()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
Paint_2/Form1.Designer.cs
generated
48
Paint_2/Form1.Designer.cs
generated
@@ -71,6 +71,7 @@
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.DebugLabel = new System.Windows.Forms.Label();
|
||||
this.panel4 = new System.Windows.Forms.Panel();
|
||||
this.btnSvgExport = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.canvas)).BeginInit();
|
||||
this.panelFile.SuspendLayout();
|
||||
this.panelDrawing.SuspendLayout();
|
||||
@@ -93,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, 32);
|
||||
this.tbxProjectName.Size = new System.Drawing.Size(225, 38);
|
||||
this.tbxProjectName.TabIndex = 0;
|
||||
this.tbxProjectName.Text = "Untitled Project";
|
||||
//
|
||||
@@ -144,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(202, 14);
|
||||
this.lblSelectedColor.Size = new System.Drawing.Size(256, 18);
|
||||
this.lblSelectedColor.TabIndex = 1;
|
||||
this.lblSelectedColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||
//
|
||||
@@ -192,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(53, 14);
|
||||
this.lblHeight.Size = new System.Drawing.Size(66, 18);
|
||||
this.lblHeight.TabIndex = 34;
|
||||
this.lblHeight.Text = "H:2000";
|
||||
//
|
||||
@@ -202,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(57, 14);
|
||||
this.lblWidth.Size = new System.Drawing.Size(69, 18);
|
||||
this.lblWidth.TabIndex = 33;
|
||||
this.lblWidth.Text = "W:2000";
|
||||
//
|
||||
@@ -238,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(120, 18);
|
||||
this.label14.Size = new System.Drawing.Size(150, 22);
|
||||
this.label14.TabIndex = 29;
|
||||
this.label14.Text = "Selected color";
|
||||
//
|
||||
@@ -273,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(202, 14);
|
||||
this.lblHoveringColor.Size = new System.Drawing.Size(256, 18);
|
||||
this.lblHoveringColor.TabIndex = 1;
|
||||
this.lblHoveringColor.Text = "Hex:FFFFFF R:255 G:255 B:255";
|
||||
//
|
||||
@@ -284,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(120, 18);
|
||||
this.label15.Size = new System.Drawing.Size(150, 22);
|
||||
this.label15.TabIndex = 29;
|
||||
this.label15.Text = "Hovering color";
|
||||
//
|
||||
@@ -307,7 +308,7 @@
|
||||
0,
|
||||
0});
|
||||
this.nupPencilWidth.Name = "nupPencilWidth";
|
||||
this.nupPencilWidth.Size = new System.Drawing.Size(55, 27);
|
||||
this.nupPencilWidth.Size = new System.Drawing.Size(55, 33);
|
||||
this.nupPencilWidth.TabIndex = 17;
|
||||
this.nupPencilWidth.Value = new decimal(new int[] {
|
||||
10,
|
||||
@@ -408,11 +409,11 @@
|
||||
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 = 14;
|
||||
this.lsbTools.ItemHeight = 18;
|
||||
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";
|
||||
this.lsbTools.Size = new System.Drawing.Size(183, 142);
|
||||
this.lsbTools.Size = new System.Drawing.Size(183, 128);
|
||||
this.lsbTools.TabIndex = 32;
|
||||
this.lsbTools.SelectedIndexChanged += new System.EventHandler(this.lsbTools_SelectedIndexChanged);
|
||||
//
|
||||
@@ -432,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(84, 16);
|
||||
this.label1.Size = new System.Drawing.Size(108, 20);
|
||||
this.label1.TabIndex = 36;
|
||||
this.label1.Text = "Paint tools";
|
||||
//
|
||||
@@ -546,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(49, 16);
|
||||
this.label3.Size = new System.Drawing.Size(63, 20);
|
||||
this.label3.TabIndex = 37;
|
||||
this.label3.Text = "Layers";
|
||||
//
|
||||
@@ -596,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, 16);
|
||||
this.label2.Size = new System.Drawing.Size(0, 20);
|
||||
this.label2.TabIndex = 36;
|
||||
//
|
||||
// DebugLabel
|
||||
@@ -604,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(48, 14);
|
||||
this.DebugLabel.Size = new System.Drawing.Size(55, 18);
|
||||
this.DebugLabel.TabIndex = 38;
|
||||
this.DebugLabel.Text = "Debug";
|
||||
//
|
||||
@@ -624,12 +625,28 @@
|
||||
this.panel4.Size = new System.Drawing.Size(507, 39);
|
||||
this.panel4.TabIndex = 37;
|
||||
//
|
||||
// btnSvgExport
|
||||
//
|
||||
this.btnSvgExport.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(59)))), ((int)(((byte)(59)))), ((int)(((byte)(59)))));
|
||||
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.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.TabIndex = 37;
|
||||
this.btnSvgExport.Text = "Export SVG";
|
||||
this.btnSvgExport.UseVisualStyleBackColor = false;
|
||||
this.btnSvgExport.Click += new System.EventHandler(this.btnSvgExport_Click);
|
||||
//
|
||||
// PaintForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 14F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
|
||||
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);
|
||||
this.Controls.Add(this.btnSvgExport);
|
||||
this.Controls.Add(this.panel4);
|
||||
this.Controls.Add(this.DebugLabel);
|
||||
this.Controls.Add(this.panel3);
|
||||
@@ -715,6 +732,7 @@
|
||||
private System.Windows.Forms.Panel pnlLayers;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Panel panel4;
|
||||
private System.Windows.Forms.Button btnSvgExport;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -468,5 +468,10 @@ namespace Paint_2
|
||||
}
|
||||
DisplayLayers();
|
||||
}
|
||||
|
||||
private void btnSvgExport_Click(object sender, EventArgs e)
|
||||
{
|
||||
Project.ConvertToSVG();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Paint_2
|
||||
void Clear();
|
||||
List<Color> GetLastColors(int colorNumber);
|
||||
void Paint(Bitmap canvas);
|
||||
string PaintSVG();
|
||||
string ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,5 +101,9 @@ namespace Paint_2
|
||||
Point result = new Point(resultX, resultY);
|
||||
return result;
|
||||
}
|
||||
public string StandartPaintSVG(List<List<Point>> Drawings,List<Color> Colors, List<int> Widths)
|
||||
{
|
||||
return "COUCOU";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,37 @@ namespace Paint_2
|
||||
drawingCounter += 1;
|
||||
}
|
||||
}
|
||||
public string PaintSVG()
|
||||
{
|
||||
string result = "";
|
||||
string newLine = Environment.NewLine;
|
||||
|
||||
//foreach (List<Point> drawing in Drawings)
|
||||
for (int drawCount = 0; drawCount < Drawings.Count; drawCount++)
|
||||
{
|
||||
Point p1;
|
||||
Point p2;
|
||||
List<Point> drawing = Drawings[drawCount];
|
||||
Color color = Colors[drawCount];
|
||||
int width = Widths[drawCount];
|
||||
for (int pointIndex = 0; pointIndex < drawing.Count; pointIndex++)
|
||||
{
|
||||
if (pointIndex >= 1)
|
||||
{
|
||||
p1 = drawing[pointIndex - 1];
|
||||
p2 = drawing[pointIndex];
|
||||
|
||||
result += "<ellipse cx=\"" + p2.X + "\" cy=\"" + p2.Y + "\" rx=\"" + width/2 + "\" ry=\"" + width/2 + "\" style=\"fill:rgb(" + color.R + ", " + color.G + ", " + color.B + ");\"/>";
|
||||
result += newLine;
|
||||
result += "<line x1=\"" + p1.X + "\" y1=\"" + p1.Y + "\" x2=\"" + p2.X + "\" y2=\"" + p2.Y + "\" style=\"stroke: rgb(" + color.R + ", " + color.G + ", " + color.B + "); stroke-width:" + width + "\"/>";
|
||||
result += newLine;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public void Start(Color color, int width)
|
||||
{
|
||||
Utils.StandartStart(color, width);
|
||||
@@ -123,5 +154,7 @@ namespace Paint_2
|
||||
result.Color = Color;
|
||||
return (Object)(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,5 +416,24 @@ namespace Paint_2
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void ConvertToSVG()
|
||||
{
|
||||
string fileContent = "";
|
||||
string newLine = Environment.NewLine;
|
||||
|
||||
fileContent += "<svg version=\"1.1\" width=\"100%\" viewbox=\"0 0 "+CanvasSize.Width+" "+CanvasSize.Height+"\" xmlns = \"http://www.w3.org/2000/svg\">";
|
||||
fileContent += newLine;
|
||||
|
||||
foreach (Sketch layer in Layers)
|
||||
{
|
||||
fileContent += "<!-- "+layer.Name+" -->";
|
||||
fileContent += newLine;
|
||||
fileContent += layer.PaintSVG();
|
||||
}
|
||||
|
||||
fileContent += newLine;
|
||||
fileContent += "</svg>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +149,11 @@ namespace Paint_2
|
||||
result.Color = Color;
|
||||
return (Object)(result);
|
||||
}
|
||||
|
||||
public string PaintSVG()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,5 +149,10 @@ namespace Paint_2
|
||||
result.Color = Color;
|
||||
return (Object)(result);
|
||||
}
|
||||
|
||||
public string PaintSVG()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,23 @@ namespace Paint_2
|
||||
CurrentTool.Paint(Drawing);
|
||||
return Drawing;
|
||||
}
|
||||
public string PaintSVG()
|
||||
{
|
||||
string result = "";
|
||||
string newLine = Environment.NewLine;
|
||||
|
||||
foreach (PaintTool tool in ToolList)
|
||||
{
|
||||
//[DEBUG] REMOVE THIS IF AFTER TESTING PLEASE
|
||||
if (tool is Pencil || tool is DotPencil)
|
||||
{
|
||||
result += "<!-- " + tool.Name + " -->";
|
||||
result += newLine;
|
||||
result += tool.PaintSVG();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public Bitmap ForcePaint()
|
||||
{
|
||||
Drawing = new Bitmap(SketchSize.Width, SketchSize.Height);
|
||||
|
||||
Reference in New Issue
Block a user