static void CreateStitches(string filename, string colormap) { var cmr = new ColorMapReader(); var colortranslations = cmr.Read(TryReadLines(colormap)); var culture = System.Globalization.CultureInfo.InvariantCulture; var r = XElement.Load(filename); var defaultMap = new List <ColorTranslation> { new ColorTranslation { Color = "#aaaa00", StepAngle = 90, LineHeight = 0.2 }, new ColorTranslation { Color = "#aa0000", StepAngle = 0, LineHeight = 0.1 }, }; colortranslations = colortranslations.Count == 0 ? defaultMap : colortranslations; var polygonList = new SvgReader(r).ExtractPolygons().ToList(); var steps = StepWriter.WriteStitches(colortranslations, polygonList); foreach (var step in steps) { Console.WriteLine(step); } }
public void RejectsLineWithWrongNumberOfFields() { var c = new ColorMapReader(); List <ColorTranslation> d = c.Read(new [] { "", "1;2;3" }); Assert.AreEqual(0, d.Count); }
public void AcceptsLineWithCorrectNumberOfFields() { var c = new ColorMapReader(); List <ColorTranslation> d = c.Read(new [] { "#aa00dd,1.2,3.0,30,0.2", "1,2,3" }); Assert.AreEqual(1, d.Count); }
public void ReadsEmptyFile() { var c = new ColorMapReader(); List <ColorTranslation> d = c.Read(new string[] {}); Assert.AreEqual(0, d.Count); }
public void ParsesDoubleFields() { var c = new ColorMapReader(); List <ColorTranslation> d = c.Read(new [] { "#aa00dd,1.2,4.0,30,0.2", "1,2,3" }); Assert.AreEqual("#aa00dd", d[0].Color); Assert.AreEqual(1.2, d[0].LineHeight); Assert.AreEqual(30, d[0].StepAngle); Assert.AreEqual(0.2, d[0].MoveInside); Assert.AreEqual(4.0, d[0].MaxStepLength); }