Beispiel #1
0
		static void Main(string[] args)
		{
			try
			{
				Page page = new Page(215, 279, SvgLengthType.SVG_LENGTHTYPE_MM);

				CircuitBoardBase circuitBoardBase = new CircuitBoardBase();
				string svgText = circuitBoardBase.BuildSvg(page);
				Save(svgText, "CircuitBoardBase.svg");

				double outerRadius = 37;
				double slotLength = 12;
				int slotCount = 40;
				double edgeOffset = 0.3;

				EncoderDisk encoderDisk = new EncoderDisk(outerRadius, 4);
				encoderDisk.OuterEncoderRing = new EncoderRing(outerRadius - edgeOffset, slotLength, slotCount, 0);
				encoderDisk.InnerEncoderRing = new EncoderRing(outerRadius - edgeOffset - slotLength, slotLength, slotCount, 180);

				svgText = encoderDisk.BuildSvg(page);
				Save(svgText, "EncoderDisk.svg");

			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}
			finally
			{
				Console.WriteLine("Done");
				Console.ReadLine();
			}
		}
		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);
		}
		private CheckerBoardBuilder(Page page, int xCount, int yCount, float squareLength)
		{
			m_Page = page;
			m_XCount = xCount;
			m_YCount = yCount;
			m_SquareLength = squareLength;

			m_UpperLeft = new PointF(
				-(xCount * squareLength) / 2.0f,
				-(yCount * squareLength) / 2.0f);
		}
		public static string BuildSvg(Page page, int xCount, int yCount, float squareLength)
		{
			CheckerBoardBuilder gridBuilder = new CheckerBoardBuilder(page, xCount, yCount, squareLength);
			return gridBuilder.BuildSvg();
		}