private string BuildSvg()
		{
			m_Root = new SvgSvgElement(
				m_Page.SvgLengthWidth, m_Page.SvgLengthHeight,
				new SvgNumList(new float[] { -m_Page.Width / 2, -m_Page.Height / 2, m_Page.Width, m_Page.Height }));

			SvgGroupElement mainGroup = new SvgGroupElement("Main");

			for (int xIndex = 0; xIndex < m_XCount; xIndex++)
			{
				for (int yIndex = 0; yIndex < m_YCount; yIndex++)
				{
					InsertSquare(mainGroup, xIndex, yIndex);
				}
			}

			m_Root.AddChild(mainGroup);
			return m_Root.WriteSVGString(true, false);
		}
Ejemplo n.º 2
0
		public string BuildSvg(Page page)
		{
			SvgSvgElement root = new SvgSvgElement(
				page.SvgLengthWidth, page.SvgLengthHeight,
				new SvgNumList(new float[] { -page.Width / 2, -page.Height / 2, page.Width, page.Height }));

			root.AddChild(CreateCenteredCircle(this.OuterRadius, s_FilledBlack));

			// Add encoder rings
			AddEncoderRing(root, this.OuterEncoderRing, 1);
			AddEncoderRing(root, this.InnerEncoderRing, 2);

			root.AddChild(CreateCenteredCircle(this.CenterHoleRadius, s_FilledWhite));

			SvgGroupElement crossLinesGroup = new SvgGroupElement("CrossLines");
			crossLinesGroup.Style = s_NormalLineStyle;
			root.AddChild(crossLinesGroup);
			AddGuideLines(crossLinesGroup, (float)this.CenterHoleRadius);

			return root.WriteSVGString(true, false);
		}
Ejemplo n.º 3
0
        public string Build()
        {
            double border = 5; // border around grahics in mm

            Wheel wheel = m_CycloidalGear.Wheel;
            Pinion pinion = m_CycloidalGear.Pinion;

            double pageWidth = wheel.Addendum + wheel.PitchDiameter + pinion.PitchDiameter + pinion.Addendum + 2 * border;
            double pageHeight = 2 * wheel.Addendum + wheel.PitchDiameter + 2 * border;
            Page page = new Page((float)pageWidth, (float)pageHeight, SvgLengthType.SVG_LENGTHTYPE_MM);

            SvgSvgElement root = new SvgSvgElement(
                page.SvgLengthWidth, page.SvgLengthHeight,
                new SvgNumList(new float[] { - (float)(wheel.Addendum + wheel.PitchDiameter / 2.0 + border), -page.Height / 2, page.Width, page.Height }));

            wheel.Center = new Point(0, 0);
            pinion.Center = wheel.Center + new Vector(m_CycloidalGear.WheelPinionDistance, 0);

            new WheelGenerator().Build(m_CycloidalGear.Wheel, root);
            new PinionGenerator().Build(m_CycloidalGear.Pinion, root);

            return root.WriteSVGString(true);
        }
Ejemplo n.º 4
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            SvgSvgElement root = new SvgSvgElement("4in", "4in", "0,0 100,100");

            //adding multiple children

            root.AddChildren(
                new SvgRectElement(5,5,5,5),
                new SvgEllipseElement(30,10,8,12),
                new SvgTextElement("Textastic!", 3, 20)
                );

            //group and path

            SvgGroupElement grp = new SvgGroupElement("green_group");

            grp.Style = "fill:green;stroke:black;";

            SvgEllipseElement ell = new SvgEllipseElement();
            ell.CX = 50;
            ell.CY = 50;
            ell.RX = 10;
            ell.RY = 20;

            SvgPathElement pathy = new SvgPathElement();
            pathy.D = "M 20,80 C 20,90 30,80 70,100 C 70,100 40,60 50,60 z";
            pathy.Style = ell.Style;

            root.AddChild(grp);

            //cloning and style arithmetic

            grp.AddChildren(ell, pathy);

            grp.Style.Set("fill", "blue");

            SvgGroupElement grp2 = (SvgGroupElement)SvgFactory.CloneElement(grp);

            grp2.Id = "cloned_red_group";

            grp2.Style.Set("fill", "red");

            grp2.Style += "opacity:0.5";

            grp2.Transform = "scale (1.2, 1.2)  translate(10)";

            root.AddChild(grp2);

            //output

            string s = root.WriteSVGString(true);

            tbOut.Text = s;

            StreamWriter tw = new StreamWriter("c:\\temp\\foo.svg", false);

            tw.Write(s);

            tw.Close();

            svgOut.SRC = "c:\\temp\\foo.svg";
        }