private IEnumerable<SvgStyledTransformedElement> GetHorizontalLines(float distance)
		{
			for (float y = this.Origin.Y; y < this.Page.Height; y += distance)
			{
				SvgLineElement lineElement = new SvgLineElement(
					GetSvgLength(0), GetSvgLength(y),
					GetSvgLength(this.Page.Width), GetSvgLength(y));

				yield return lineElement;
			}
		}
		private void AddGuideLines(SvgGroupElement group, float radius)
		{
			SvgLineElement verticalLineElement = new SvgLineElement(
				0, radius,
				0, -radius);
			group.AddChild(verticalLineElement);

			SvgLineElement horizontalLineElement = new SvgLineElement(
				-radius, 0,
				radius, 0);
			group.AddChild(horizontalLineElement);
		}
		private IEnumerable<SvgStyledTransformedElement> GetVerticalLines(float distance)
		{
			int halfCount = (int)((this.Page.Width - this.Origin.X) / distance);
			for (int i = -halfCount; i <= halfCount; i++)
			{
				float x = this.Origin.X + i * distance;
				SvgLineElement lineElement = new SvgLineElement(
					GetSvgLength(x), GetSvgLength(0),
					GetSvgLength(x), GetSvgLength(this.Page.Height));

				yield return lineElement;
			}
		}
		public void AddAlignmentLines()
		{
			SvgGroupElement alinmentLinesGroup = new SvgGroupElement("AlignmentLines");
			alinmentLinesGroup.Style = s_AlignmentLineStyle;

			SvgLineElement line1 = new SvgLineElement(
				GetSvgLength(this.Origin.X), GetSvgLength(0),
				GetSvgLength(this.Origin.X), GetSvgLength(this.Page.Width));
			alinmentLinesGroup.AddChild(line1);

			SvgLineElement line2 = new SvgLineElement(
				GetSvgLength(0), GetSvgLength(this.Origin.Y),
				GetSvgLength(this.Page.Width), GetSvgLength(this.Origin.Y));
			alinmentLinesGroup.AddChild(line2);

			float radius = 65;
			SvgEllipseElement cutOutCircle = new SvgEllipseElement(
				GetSvgLength(this.Origin.X), GetSvgLength(this.Origin.Y),
				GetSvgLength(radius), GetSvgLength(radius));
			alinmentLinesGroup.AddChild(cutOutCircle);

			this.Root.AddChild(alinmentLinesGroup);
		}
예제 #5
0
        /// <summary>
        /// Implemented
        /// </summary>
        public void DrawLine(Pen pen, Single x1, Single y1, Single x2, Single y2)
        {
            SvgLineElement lin = new SvgLineElement(x1, y1, x2, y2);
            lin.Style = new SvgStyle(pen);
            if (!_transforms.Result.IsIdentity)
                lin.Transform = new SvgTransformList(_transforms.Result.Clone());
            _cur.AddChild(lin);

            DrawEndAnchors(pen, new PointF(x1, y1), new PointF(x2, y2));
        }
예제 #6
0
        private void AddHatchBrushDetails(SvgPatternElement patty, SvgColor col, HatchStyle hs)
        {
            SvgStyledTransformedElement l1=null;
            SvgStyledTransformedElement l2 = null;
            SvgStyledTransformedElement l3 = null;
            SvgStyledTransformedElement l4 = null;

            switch(hs)
            {
                case HatchStyle.Cross:
                    l1 = new SvgLineElement(4,0,4,8);
                    l2 = new SvgLineElement(0,4,8,4);
                    break;

                case HatchStyle.BackwardDiagonal:
                    l1 = new SvgLineElement(8,0,0,8);
                    break;

                case HatchStyle.LightDownwardDiagonal:
                case HatchStyle.DarkDownwardDiagonal:
                    l1 = new SvgLineElement(4,0,8,4);
                    l2 = new SvgLineElement(0,4,4,8);
                    l3 = new SvgLineElement(0,0,8,8);
                    break;
                case HatchStyle.LightHorizontal:
                case HatchStyle.DarkHorizontal:
                    l1 = new SvgLineElement(0,2,8,2);
                    l2 = new SvgLineElement(0,6,8,6);
                    break;
                case HatchStyle.LightUpwardDiagonal:
                case HatchStyle.DarkUpwardDiagonal:
                    l1 = new SvgLineElement(0,4,4,0);
                    l2 = new SvgLineElement(4,8,8,4);
                    l3 = new SvgLineElement(0,8,8,0);
                    break;
                case HatchStyle.LightVertical:
                case HatchStyle.DarkVertical:
                    l1 = new SvgLineElement(2,0,2,8);
                    l2 = new SvgLineElement(6,0,6,8);
                    break;
                case HatchStyle.DashedDownwardDiagonal:
                    l1 = new SvgLineElement(0,0,4,4);
                    l2 = new SvgLineElement(4,0,8,4);
                    break;
                case HatchStyle.DashedHorizontal:
                    l1 = new SvgLineElement(0,2,4,2);
                    l2 = new SvgLineElement(4,6,8,6);
                    break;
                case HatchStyle.DashedUpwardDiagonal:
                    l1 = new SvgLineElement(4,0,0,4);
                    l2 = new SvgLineElement(8,0,4,4);
                    break;
                case HatchStyle.DashedVertical:
                    l1 = new SvgLineElement(2,0,2,4);
                    l2 = new SvgLineElement(6,4,6,8);
                    break;
                case HatchStyle.DiagonalBrick:
                    l1 = new SvgLineElement(0,8,8,0);
                    l2 = new SvgLineElement(0,0,4,4);
                    break;
                case HatchStyle.DiagonalCross:
                    l1 = new SvgLineElement(0,0,8,8);
                    l2 = new SvgLineElement(8,0,0,8);
                    break;
                case HatchStyle.Divot:
                    l1 = new SvgLineElement(2,2,4,4);
                    l2 = new SvgLineElement(4,4,2,6);
                    break;
                case HatchStyle.DottedDiamond:
                    l1 = new SvgLineElement(0,0,8,8);
                    l2 = new SvgLineElement(0,8,8,0);
                    break;
                case HatchStyle.DottedGrid:
                    l1 = new SvgLineElement(4,0,4,8);
                    l2 = new SvgLineElement(0,4,8,4);
                    break;
                case HatchStyle.ForwardDiagonal:
                    l1 = new SvgLineElement(0,0,8,8);
                    break;
                case HatchStyle.Horizontal:
                    l1 = new SvgLineElement(0,4,8,4);
                    break;
                case HatchStyle.HorizontalBrick:
                    l1 = new SvgLineElement(0,3,8,3);
                    l2 = new SvgLineElement(3,0,3,3);
                    l3 = new SvgLineElement(0,3,0,7);
                    l4 = new SvgLineElement(0,7,7,7);
                    break;
                case HatchStyle.LargeCheckerBoard:
                    l1 = new SvgRectElement(0,0,3f,3f);
                    l2 = new SvgRectElement(4,4,4,4f);
                    break;
                case HatchStyle.LargeConfetti:
                    l1 = new SvgRectElement(0,0,1,1);
                    l2 = new SvgRectElement(2,3,1,1);
                    l3 = new SvgRectElement(5,2,1,1);
                    l4 = new SvgRectElement(6,6,1,1);
                    break;
                case HatchStyle.NarrowHorizontal:
                    l1 = new SvgLineElement(0,1,8,1);
                    l2 = new SvgLineElement(0,3,8,3);
                    l3 = new SvgLineElement(0,5,8,5);
                    l4 = new SvgLineElement(0,7,8,7);
                    break;
                case HatchStyle.NarrowVertical:
                    l1 = new SvgLineElement(1,0,1,8);
                    l2 = new SvgLineElement(3,0,3,8);
                    l3 = new SvgLineElement(5,0,5,8);
                    l4 = new SvgLineElement(7,0,7,8);
                    break;
                case HatchStyle.OutlinedDiamond:
                    l1 = new SvgLineElement(0,0,8,8);
                    l2 = new SvgLineElement(8,0,0,8);
                    break;
                case HatchStyle.Plaid:
                    l1 = new SvgLineElement(0,0,8,0);
                    l2 = new SvgLineElement(0,3,8,3);
                    l3 = new SvgRectElement(0,4,3,3);
                    break;
                case HatchStyle.Shingle:
                    l1 = new SvgLineElement(0,2,2,0);
                    l2 = new SvgLineElement(2,0,7,5);
                    l3 = new SvgLineElement(0,3,3,7);
                    break;
                case HatchStyle.SmallCheckerBoard:
                    l1 = new SvgRectElement(0,0,1,1);
                    l2 = new SvgRectElement(4,4,1,1);
                    l3 = new SvgRectElement(4,0,1,1);
                    l4 = new SvgRectElement(0,4,1,1);
                    break;
                case HatchStyle.SmallConfetti:
                    l1 = new SvgLineElement(0,0,2,2);
                    l2 = new SvgLineElement(7,3,5,5);
                    l3 = new SvgLineElement(2,6,4,4);
                    break;
                case HatchStyle.SmallGrid:
                    l1 = new SvgLineElement(0,2,8,2);
                    l2 = new SvgLineElement(0,6,8,6);
                    l3 = new SvgLineElement(2,0,2,8);
                    l4 = new SvgLineElement(6,0,6,8);
                    break;
                case HatchStyle.SolidDiamond:
                    l1 = new SvgPolygonElement("3 0 6 3 3 6 0 3");
                    break;
                case HatchStyle.Sphere:
                    l1 = new SvgEllipseElement(3,3,2,2);
                    break;
                case HatchStyle.Trellis:
                    l1 = new SvgLineElement(0,1,8,1);
                    l2 = new SvgLineElement(0,3,8,3);
                    l3 = new SvgLineElement(0,5,8,5);
                    l4 = new SvgLineElement(0,7,8,7);
                    break;
                case HatchStyle.Vertical:
                    l4 = new SvgLineElement(0,0,0,8);
                    break;
                case HatchStyle.Wave:
                    l3 = new SvgLineElement(0,4,3,2);
                    l4 = new SvgLineElement(3,2,8,4);
                    break;
                case HatchStyle.Weave:
                    l1 = new SvgLineElement(0,4,4,0);
                    l2 = new SvgLineElement(8,4,4,8);
                    l3 = new SvgLineElement(0,0,0,4);
                    l4 = new SvgLineElement(0,4,4,8);
                    break;
                case HatchStyle.WideDownwardDiagonal:
                    l1 = new SvgLineElement(0,0,8,8);
                    l2 = new SvgLineElement(0,1,8,9);
                    l3 = new SvgLineElement(7,0,8,1);
                    break;
                case HatchStyle.WideUpwardDiagonal:
                    l1 = new SvgLineElement(8,0,0,8);
                    l2 = new SvgLineElement(8,1,0,9);
                    l3 = new SvgLineElement(0,1,-1,0);
                    break;
                case HatchStyle.ZigZag:
                    l1 = new SvgLineElement(0,4,4,0);
                    l2 = new SvgLineElement(4,0,8,4);
                    break;

                case HatchStyle.Percent05:
                    l1 = new SvgLineElement(0,0,1,0);
                    l2 = new SvgLineElement(4,4,5,4);
                    break;
                case HatchStyle.Percent10:
                    l1 = new SvgLineElement(0,0,1,0);
                    l2 = new SvgLineElement(4,2,5,2);
                    l3 = new SvgLineElement(2,4,3,4);
                    l4 = new SvgLineElement(6,6,7,6);
                    break;
                case HatchStyle.Percent20:
                    l1 = new SvgLineElement(0,0,2,0);
                    l2 = new SvgLineElement(4,2,6,2);
                    l3 = new SvgLineElement(2,4,4,4);
                    l4 = new SvgLineElement(5,6,7,6);
                    break;
                case HatchStyle.Percent25:
                    l1 = new SvgLineElement(0,0,3,0);
                    l2 = new SvgLineElement(4,2,6,2);
                    l3 = new SvgLineElement(2,4,5,4);
                    l4 = new SvgLineElement(5,6,7,6);
                    break;
                case HatchStyle.Percent30:
                    l1 = new SvgRectElement(0,0,3,1);
                    l2 = new SvgLineElement(4,2,6,2);
                    l3 = new SvgRectElement(2,4,3,1);
                    l4 = new SvgLineElement(5,6,7,6);
                    break;
                case HatchStyle.Percent40:
                    l1 = new SvgRectElement(0,0,3,1);
                    l2 = new SvgRectElement(4,2,3,1);
                    l3 = new SvgRectElement(2,4,3,1);
                    l4 = new SvgRectElement(5,6,3,1);
                    break;
                case HatchStyle.Percent50:
                    l1 = new SvgRectElement(0,0,3,3);
                    l2 = new SvgRectElement(4,4,4,4f);
                    break;
                case HatchStyle.Percent60:
                    l1 = new SvgRectElement(0,0,4,3);
                    l2 = new SvgRectElement(4,4,4,4f);
                    break;
                case HatchStyle.Percent70:
                    l1 = new SvgRectElement(0,0,4,5);
                    l2 = new SvgRectElement(4,4,4,4f);
                    break;
                case HatchStyle.Percent75:
                    l1 = new SvgRectElement(0,0,7,3);
                    l2 = new SvgRectElement(0,2,3,7);
                    break;
                case HatchStyle.Percent80:
                    l1 = new SvgRectElement(0,0,7,4);
                    l2 = new SvgRectElement(0,2,4,7);
                    break;
                case HatchStyle.Percent90:
                    l1 = new SvgRectElement(0,0,7,5);
                    l2 = new SvgRectElement(0,2,5,7);
                    break;

                default:

                    break;
            }

            if (l1 != null)
            {
                l1.Style.Set("stroke", col);
                l1.Style.Set("fill", col);
                patty.AddChild(l1);
            }
            if (l2 != null)
            {
                l2.Style.Set("stroke", col);
                l2.Style.Set("fill", col);
                patty.AddChild(l2);
            }
            if (l3 != null)
            {
                l3.Style.Set("stroke", col);
                l3.Style.Set("fill", col);
                patty.AddChild(l3);
            }
            if (l4 != null)
            {
                l4.Style.Set("stroke", col);
                l4.Style.Set("fill", col);
                patty.AddChild(l4);
            }
        }
		private IEnumerable<SvgStyledTransformedElement> GetAngleLines(double deltaAngleDegree, float innerRadius)
		{
			//float outerRadius = (float)Math.Sqrt(this.Page.Width * this.Page.Width + this.Page.Height * this.Page.Height);

			int halfCount = (int)(90 / deltaAngleDegree);
			for (int i = -halfCount; i <= halfCount; i++)
			{
				double angle = (i * deltaAngleDegree) / 180.0 * Math.PI;
				PointF startingPoint = new PointF(
					(float)(Math.Sin(angle) * innerRadius) + this.Origin.X,
					(float)(Math.Cos(angle) * innerRadius) + this.Origin.Y);

				double outerRadius = GetOuterRadius(angle);
				PointF endPoint = new PointF(
					(float)(Math.Sin(angle) * outerRadius) + this.Origin.X,
					(float)(Math.Cos(angle) * outerRadius) + this.Origin.Y);

				SvgLineElement lineElement = new SvgLineElement(
					GetSvgLength(startingPoint.X), GetSvgLength(startingPoint.Y),
					GetSvgLength(endPoint.X), GetSvgLength(endPoint.Y));

				yield return lineElement;
			}
		}
예제 #8
0
        /// <summary>
        /// Implemented
        /// </summary>
        public void DrawLine(Pen pen, Single x1, Single y1, Single x2, Single y2)
        {
            if (IsEndAnchorSimple(pen.StartCap) && IsEndAnchorSimple(pen.EndCap))
            {
                // This code works, but not for CustomLineCup style
                SvgLineElement lin = new SvgLineElement(x1, y1, x2, y2);
                lin.Style = new SvgStyle(pen);
                if (!_transforms.Result.IsIdentity)
                    lin.Transform = new SvgTransformList(_transforms.Result.Clone());
                _cur.AddChild(lin);

                DrawEndAnchors(pen, new PointF(x1, y1), new PointF(x2, y2));
            }
            else
            {
                DrawLines(pen, new PointF[] { new PointF(x1, y1), new PointF(x2, y2) });
            }
        }
		private void AddCenteredTriangle(SvgGroupElement group, float sideLength, float radius)
		{
			float middleLineLength = sideLength * (float)Math.Cos(30 / 180.0 * Math.PI);
			float centerToBase = middleLineLength - radius;

			SvgLineElement sideLineElement1 = new SvgLineElement(
				-sideLength/2f, -centerToBase,
				sideLength/2f, -centerToBase);
			group.AddChild(sideLineElement1);

			SvgLineElement sideLineElement2 = new SvgLineElement(
				sideLength/2f, -centerToBase,
				0, middleLineLength - centerToBase);
			group.AddChild(sideLineElement2);

			SvgLineElement sideLineElement3 = new SvgLineElement(
				0, middleLineLength - centerToBase,
				-sideLength/2f, -centerToBase);
			group.AddChild(sideLineElement3);
		}
		private void AddRays(SvgGroupElement group, float radius)
		{
			double[] angles = { 90, 150, 210, 270, 330, 30 }; //, 120, 180, 240, 300 };

			foreach (double angle in angles)
			{
				SvgLineElement rayElement = new SvgLineElement(
					0, 0,
					radius * (float)Math.Cos(angle * Math.PI / 180), radius * (float)Math.Sin(angle * Math.PI / 180));
				group.AddChild(rayElement);
			}
		}