static async Task Main(string[] args) { var cts = new CancellationTokenSource(10000); var file = new DstFile(File.OpenRead(args[0])); await file.Read(cts.Token); File.WriteAllText("out.txt", CommandWriter.Write(file), Encoding.UTF8); File.WriteAllText("out.svg", SvgWriter.Write(file), Encoding.UTF8); }
public static string Write(DstFile input) { var sb = new StringBuilder(); foreach (var element in input.Body.Stitches) { var signedX = $"{(element.X >= 0 ? "+" : "")}{element.X}"; var signedY = $"{(element.Y >= 0 ? "+" : "")}{element.Y}"; sb.Append($"{element.CommandType}\t{signedX.PadLeft(3)}\t{signedY.PadLeft(3)}\n"); } return(sb.ToString()); }
public static string Write(DstFile file) { var extents = file.Body.Extents; var width = extents.MaxX - extents.MinX; var height = extents.MaxY - extents.MinY; var viewBox = $"{extents.MinX} {extents.MinY} {width} {height}"; var sb = new StringBuilder(); sb.Append( "<?xml version='1.0'?>" + $"<svg version='1.1' xmlns='http://www.w3.org/2000/svg' width='{width}' height='{height}' viewBox='{viewBox}'>"); foreach (var block in file.Body.GetStitchBlocks()) { sb.AppendFormat("<path d='M{0}' fill='none' stroke='#1f1436' stroke-width='3'></path>", string.Join("", block.Select(stitch => $" {stitch.X},{stitch.Y}"))); } sb.Append("</svg>"); return(sb.ToString()); }
public QrcodeDst() { _dst = new DstFile(); _stitchGen = new QrCodeStitcher(); }