public void Circles(SVG svgDoc, XmlNode parent, Attr attr) { int oldIndex = this.genes.Index; this.genes.Index = DEFAULT_CIRCLE_INDEX; XmlNode mainGroup = svgDoc.Group(parent, attr); int numRings = (int)(this.genes.Next() * (float)CIRCLE_RING_RANGE) + CIRCLE_RING_MIN; int harmonic = this.harmonic; for (int r = 0; r < numRings; r++) { int numCircs = (int)((this.genes.Next() * (float)CIRCLE_CIRC_RANGE) + CIRCLE_CIRC_MIN) * harmonic; float circRadii = this.genes.Next() * CIRC_RADII_MAX; float ringRadii = this.genes.Next() * CIRC_RADII_MAX; float angCirc = (float)(Math.PI * 2.0) / (float)numCircs; float ringPhase = this.genes.Next() < 0.5f ? 0.0f : (angCirc * 0.5f); float strokeWidth = this.genes.Next() * MAX_STROKE_WIDTH; for (int c = 0; c < numCircs; c++) { float cx = (float)Math.Sin(angCirc * c) * ringRadii + MIDX; float cy = (float)Math.Cos(angCirc * c) * ringRadii + MIDY; svgDoc.Circle(mainGroup, cx, cy, circRadii, new Attr() { {"fill", "none"}, {"stroke", "black"}, {"stroke-width", strokeWidth.ToString("0.###")} }); } } this.genes.Index = oldIndex; }
public static void StartTest(String testName = "all") { //start testing Console.WriteLine("Starting Testing..."); /* SVG testDoc = new SVG(new Attr() { {"width" , "1000"}, {"height" , "1000"} }); */ SVG testDoc = new SVG(); if (testName == "defs" || testName == "all") { Console.WriteLine("Testing AddToDefs method..."); XmlDocument newDef = new XmlDocument(); newDef.LoadXml("<g>" + "<helloDefs/>" + "</g>" ); testDoc.AddToDefs(newDef); } if (testName == "group" || testName == "all") { Console.WriteLine("Testing Group method..."); testDoc.Group(testDoc.root, new Attr() { { "GROUP_TEST", "TESTED" } }); } if (testName == "use" || testName == "all") { Console.WriteLine("Testing Use method..."); testDoc.Use(testDoc.root, "TESTED"); } if (testName == "rect" || testName == "all") { Console.WriteLine("Testing Rect method..."); testDoc.Rect(testDoc.root, 0.0f, 1.0f, 2.0f, 3.0f, 3.0f, 4.0f, new Attr() { { "RECT_TEST", "TESTED" } }); } if (testName == "circle" || testName == "all") { Console.WriteLine("Testing Circle method..."); testDoc.Circle(testDoc.root, 0.0f, 1.0f, 2.0f, new Attr() { { "CIRCLE_TEST", "TESTED" } }); } if (testName == "ellipse" || testName == "all") { Console.WriteLine("Testing Ellipse method..."); testDoc.Ellipse(testDoc.root, 0.0f, 1.0f, 2.0f, 3.0f, new Attr() { { "ELLIPSE_TEST", "TESTED" } }); } if (testName == "line" || testName == "all") { Console.WriteLine("Testing Line method..."); testDoc.Line(testDoc.root, 0.0f, 1.0f, 2.0f, 3.0f, new Attr() { { "LINE_TEST", "TESTED" } }); } testDoc.svgDoc.Save(Console.Out); Console.WriteLine(); }