This commit is contained in:
2021-08-10 19:06:54 +00:00
parent d62b8afa4e
commit 7b9165f5c5
2 changed files with 42 additions and 26 deletions

View File

@@ -663,6 +663,8 @@ namespace AyaNova
Console.WriteLine("Forced immediate shutdown: Ctrl-c key combination");
Console.WriteLine("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
_newLog.LogInformation(SigV7Util.v7StrokePathTov8SVG("71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5,61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5,62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5,48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219"));
}

View File

@@ -7,10 +7,8 @@ namespace AyaNova.Util
{
public static string v7StrokePathTov8SVG(string spath)
{
string svg=string.Empty;
List<Tuple<int,int>> lPoints = new List<Tuple<int, int>>();
List<Tuple<int, int>> lPoints = new List<Tuple<int, int>>();
string[] sLines = spath.Split('X');
@@ -19,37 +17,53 @@ namespace AyaNova.Util
string[] sPoints = sLine.Trim().Split(' ');
if (sPoints.Length > 0)
{
{
foreach (string s in sPoints)
{
lPoints.Add(StringToPoint(s));
}
}
}
/*
71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5,
61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5,
62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5,
48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219
*/
/*
71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5,
61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5,
62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5,
48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219
*/
//"71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5,61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5,62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5,48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219"
//Now turn lPoints into svg and return
// <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 552 120" width="552" height="120"><path d="M 79.400,15.300 C 82.236,17.326 82.400,16.800 85.400,18.300" stroke-width="5.525" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path><path d="M 85.400,18.300 C 88.884,19.030 88.736,19.326 92.400,19.300" stroke-wke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path><path d="M 510.400,91.300 C 513.725,93.769 513.448,93.840 517.400,95.300" stroke-width="4.888" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path><path d="M 517.400,95.300 C 519.870,96.105 519.725,96.269 522.400,96.300" stroke-width="5.121" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path></svg>
//https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
//NOTE: v7 sigpad is 300 by 100 pixels
//so first guess is to treat the canvas as that size for svg
//
//"71.5,77.19999694824219 71.5,79.19999694824219 71.5,83.19999694824219 71.5,91.19999694824219 74.5,101.19999694824219 75.5,103.19999694824219 80.5,104.19999694824219 86.5,104.19999694824219 96.5,101.19999694824219 116.5,91.19999694824219 145.5,75.19999694824219 167.5,61.19999694824219 183.5,50.19999694824219 194.5,42.19999694824219 197.5,42.19999694824219 199.5,51.19999694824219 202.5,66.19999694824219 210.5,87.19999694824219 219.5,94.19999694824219 235.5,97.19999694824219 260.5,89.19999694824219 298.5,74.19999694824219 326.5,62.19999694824219 339.5,56.19999694824219 343.5,58.19999694824219 345.5,62.19999694824219 349.5,74.19999694824219 357.5,87.19999694824219 368.5,97.19999694824219 387.5,99.19999694824219 423.5,89.19999694824219 465.5,71.19999694824219 498.5,55.19999694824219 511.5,48.19999694824219 514.5,52.19999694824219 514.5,57.19999694824219 515.5,65.19999694824219 515.5,67.19999694824219 518.5,67.19999694824219 521.5,67.19999694824219 521.5,67.19999694824219"
//Now turn lPoints into svg and return
// <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 552 120" width="552" height="120">
//<path d="M 79.400,15.300 C 82.236,17.326 82.400,16.800 85.400,18.300" stroke-width="5.525" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path>
//<path d="M 85.400,18.300 C 88.884,19.030 88.736,19.326 92.400,19.300" stroke-wke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path><path d="M 510.400,91.300 C 513.725,93.769 513.448,93.840 517.400,95.300" stroke-width="4.888" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path><path d="M 517.400,95.300 C 519.870,96.105 519.725,96.269 522.400,96.300" stroke-width="5.121" stroke="rgb(0, 0, 0)" fill="none" stroke-linecap="round"></path></svg>
//https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
//NOTE: v7 sigpad is 300 by 100 pixels
//so first guess is to treat the canvas as that size for svg
//
return svg;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
//open
sb.Append("<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 300 100\" width=\"300\" height=\"100\">");
//draw
sb.Append($"<path d=\"M {lPoints[0]} C ");
foreach(var p in lPoints){
sb.Append($"{p} ");
}
sb.Append("\" stroke-width=\"5.525\" stroke=\"rgb(0, 0, 0)\" fill=\"none\" stroke-linecap=\"round\"></path>");
//close
sb.Append("</svg>");
return sb.ToString();
}
private static Tuple<int,int> StringToPoint(string s)
private static Tuple<int, int> StringToPoint(string s)
{
if (string.IsNullOrWhiteSpace(s))
return new Tuple<int, int>(0, 0);
return new Tuple<int, int>(0, 0);
if (!s.Contains(','))
return new Tuple<int, int>(0, 0);
@@ -63,7 +77,7 @@ namespace AyaNova.Util
{
// if it contains a decimal then convert differently
return new Tuple<int, int>(
Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[0]))),
Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[0]))),
Convert.ToInt32(Math.Round(Convert.ToDouble(spoint[1])))
);
// return new Point(
@@ -78,17 +92,17 @@ namespace AyaNova.Util
//in their signature stroke path string.
try
{
return new Tuple<int,int>(int.Parse(spoint[0]), int.Parse(spoint[1]));
return new Tuple<int, int>(int.Parse(spoint[0]), int.Parse(spoint[1]));
}
catch (System.FormatException )
catch (System.FormatException)
{
return new Tuple<int, int>(0, 0);
}
}
}