public string BuildSvg(Page page)
		{
			//this.Page = page;
			//this.Origin = new PointF(page.Width / 2, page.Height / 2);

			this.Root = new SvgSvgElement(
				page.SvgLengthWidth, page.SvgLengthHeight,
				new SvgNumList(new float[] { -page.Width / 2, -page.Height / 2, page.Width, page.Height }));

			SvgGroupElement mainGroup = new SvgGroupElement("Main");
			mainGroup.Style = s_MajorLineStyle;
			this.Root.AddChild(mainGroup);

			float outerRadius = 40f;

			AddCenteredCircle(mainGroup, outerRadius);
			AddCenteredCircle(mainGroup, 24.7f);
			AddCenteredCircle(mainGroup, 7.5f);
			AddGuideLines(mainGroup, outerRadius);

			float sideLength = 59f;
			float radius = sideLength / 2f / (float)Math.Cos(30.0 / 180.0 * Math.PI);
			AddCenteredTriangle(mainGroup, sideLength, radius);
			AddCenteredCircle(mainGroup, radius);

			AddRays(mainGroup, outerRadius);

			return this.Root.WriteSVGString(true, false);
		}
Exemplo n.º 2
0
		private void AddEncoderRing(SvgSvgElement root, EncoderRing encoderRing, int index)
		{
			if (encoderRing == null)
			{
				return;
			}

			encoderRing.InsertSvg(root, index);
		}
		public GridBuilder2(Page page, float originOffset)
		{
			this.Page = page;

			this.Origin = new PointF(this.Page.Width / 2, originOffset);
			this.Root = new SvgSvgElement(
				GetSvgLength(this.Page.Width),
				GetSvgLength(this.Page.Height));
		}
Exemplo n.º 4
0
		public void InsertSvg(SvgSvgElement root, int index)
		{
			SvgGroupElement slicesGroup = new SvgGroupElement("Slices" + index.ToString());
			slicesGroup.Style = s_FilledWhite;
			root.AddChild(slicesGroup);

			InsertSlices(slicesGroup);
			// Add inner black disk
			root.AddChild(EncoderDisk.CreateCenteredCircle(this.OuterRadius - this.SlotLength, s_FilledBlack));
		}
Exemplo n.º 5
0
        internal void Build(Pinion pinion, SvgSvgElement root)
        {
            SvgGroupElement helperLinesGroup = new SvgGroupElement("HelperLines");
            helperLinesGroup.Style = Styles.HelperLineStyle;
            root.AddChild(helperLinesGroup);

            // Wheel pitch circle
            helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0));

            // Wheel addendum circle
            helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 + pinion.Addendum));

            // Wheel dedendum circle
            helperLinesGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.PitchDiameter / 2.0 - pinion.Dedendum));

            // wheel center
            double halfCrossLength = 10;
            helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X - halfCrossLength, pinion.Center.Y, pinion.Center.X + halfCrossLength, pinion.Center.Y));
            helperLinesGroup.AddChild(new SvgLineElement(pinion.Center.X, pinion.Center.Y - halfCrossLength, pinion.Center.X, pinion.Center.Y + halfCrossLength));

            SvgGroupElement mainGroup = new SvgGroupElement("Main");
            mainGroup.Style = Styles.MinorLineStyle;
            root.AddChild(mainGroup);

            PinionTooth[] teeth = pinion.GetTeeth(Math.PI / pinion.ToothCount);
            StringBuilder pathBuilder = new StringBuilder();

            pathBuilder.AppendFormat(CultureInfo.InvariantCulture, "M{0},{1}", (float)teeth[0].DedendumIntersectLeft.X, (float)teeth[0].DedendumIntersectLeft.Y);
            for (int i = 0; i < teeth.Length; i++)
            {
                PinionTooth tooth = teeth[i];
                PinionTooth nextTooth = teeth[(i + 1) % teeth.Length];
                InsertToothPath(pinion, tooth, nextTooth, pathBuilder);
            }
            pathBuilder.Append(" z");

            SvgPath svgPath = new SvgPath(pathBuilder.ToString());
            SvgPathElement svgPathElement = new SvgPathElement();
            svgPathElement.D = svgPath;

            mainGroup.AddChild(svgPathElement);

            if (pinion.CenterHoleDiameter > 0)
            {
                mainGroup.AddChild(SvgHelper.CreateCircle(pinion.Center, pinion.CenterHoleDiameter / 2.0));
            }
        }
		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);
		}
Exemplo n.º 7
0
        public SvgGraphics()
        {
            _root = new SvgSvgElement();
            _root.Id = "SvgGdi_output";

            _bg = new SvgRectElement(0, 0, "100%", "100%");
            _bg.Style.Set("fill", new SvgColor(Color.FromName("Control")));
            _bg.Id = "background";
            _root.AddChild(_bg);

            _topgroup = new SvgGroupElement("root_group");
            _topgroup.Style.Set("shape-rendering", "crispEdges");
            _cur = _topgroup;
            _root.AddChild(_topgroup);

            _defs = new SvgDefsElement("clips_hatches_and_gradients");
            _root.AddChild(_defs);

            _transforms = new MatrixStack();
        }
Exemplo n.º 8
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);
		}
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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";
        }
Exemplo n.º 11
0
        ///<summary>
        /// Constructs a new <c>SVGGraphics</c> object.
        ///</summary>
        public SvgGraphics(int width, int height)
        {
            root = new SvgSvgElement(width, height);

            //bg = new SvgRectElement(0, 0, "100%", "100%");
            //bg.Style.Set("fill", new SvgColor(Color.FromName("Control")));
            //bg.Id = "background";
            //root.AddChild(bg);

            topgroup = new SvgGroupElement();
            topgroup.Style.Set("shape-rendering", "crispEdges");
            cur = topgroup;
            root.AddChild(topgroup);

            defs = new SvgDefsElement();
            root.AddChild(defs);

            transforms = new MatrixStack();
        }