예제 #1
0
        /// <summary>
        /// PointD constructor
        /// </summary>
        /// <param name="L1">Line 1</param>
        /// <param name="L2">Line 2</param>
        public PointD
        (
            LineD L1,
            LineD L2
        )
        {
            double Denom = L1.DX * L2.DY - L1.DY * L2.DX;

            if (Denom == 0.0)
            {
                X = double.NaN;
                Y = double.NaN;
                return;
            }

            double L1DXY = L1.P2.X * L1.P1.Y - L1.P2.Y * L1.P1.X;
            double L2DXY = L2.P2.X * L2.P1.Y - L2.P2.Y * L2.P1.X;

            X = (L1DXY * L2.DX - L2DXY * L1.DX) / Denom;
            Y = (L1DXY * L2.DY - L2DXY * L1.DY) / Denom;
            return;
        }
예제 #2
0
        public PointD
        (
            LineD L1,
            LineD L2
        )
        {
            Double L1DX = L1.DX;
            Double L1DY = L1.DY;
            Double L2DX = L2.DX;
            Double L2DY = L2.DY;

            Double Denom = L1DX * L2DY - L1DY * L2DX;

            if (Denom == 0.0)
            {
                X = Double.NaN;
                Y = Double.NaN;
                return;
            }

            X = (L1.DXY * L2.DX - L2.DXY * L1.DX) / Denom;
            Y = (L1.DXY * L2.DY - L2.DXY * L1.DY) / Denom;
            return;
        }
예제 #3
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw double Bezier path
        /// </summary>
        /// <param name="CenterLine">Center line</param>
        /// <param name="Factor1">Factor 1</param>
        /// <param name="Alpha1">Alpha 1</param>
        /// <param name="Factor2">Factor 2</param>
        /// <param name="Alpha2">Alpha 2</param>
        /// <param name="PP">Paint operator</param>
        ////////////////////////////////////////////////////////////////////
        public void DrawDoubleBezierPath(
			LineD		CenterLine,
			Double		Factor1,
			Double		Alpha1,
			Double		Factor2,
			Double		Alpha2,
			PaintOp		PP
			)
        {
            // two symmetric Bezier curves
            DrawBezier(new BezierD(CenterLine.P1, Factor1, -0.5 * Alpha1, Factor2, -0.5 * Alpha2, CenterLine.P2), BezierPointOne.MoveTo);
            DrawBezier(new BezierD(CenterLine.P2, Factor2, Math.PI + 0.5 * Alpha2, Factor1, Math.PI + 0.5 * Alpha1, CenterLine.P1), BezierPointOne.Ignore);

            // set paint operator
            SetPaintOp(PP);
             		return;
        }
예제 #4
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw star
        /// </summary>
        /// <param name="Center">Center position</param>
        /// <param name="Radius">Radius</param>
        /// <param name="Alpha">Initial angle</param>
        /// <param name="Sides">Number of sides</param>
        /// <param name="PP">Paint operator</param>
        ////////////////////////////////////////////////////////////////////
        public void DrawStar(
			PointD		Center,
			Double		Radius,
			Double		Alpha,
			Int32		Sides,
			PaintOp		PP
			)
        {
            // inner radius
            Double Radius1 = 0;

            // for polygon with less than 5, set inner radius to half the main radius
            if(Sides < 5)
            {
            Radius1 = 0.5 * Radius;
            }

            // for polygons with 5 sides, calculate inner radius
            else
            {
            // polygon angle
            Double DeltaAlpha = 2.0 * Math.PI / Sides;

            // first line
            LineD L1 = new LineD(new PointD(Center, Radius, Alpha), new PointD(Center, Radius, Alpha + 2.0 * DeltaAlpha));

            // second line
            LineD L2 = new LineD(new PointD(Center, Radius, Alpha - DeltaAlpha), new PointD(Center, Radius, Alpha + DeltaAlpha));

            // inner radius
            Radius1 = (new PointD(L1, L2)).Distance(Center);
            }

            // draw star
            DrawStar(Center, Radius, Radius1, Alpha, Sides, PP);
             		return;
        }
예제 #5
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw line with given line width
        /// </summary>
        /// <param name="Line">Line</param>
        /// <param name="LineWidth">Line width</param>
        ////////////////////////////////////////////////////////////////////
        public void DrawLine(
			LineD		Line,
			Double		LineWidth
			)
        {
            DrawLine(Line.P1.X, Line.P1.Y, Line.P2.X, Line.P2.Y, LineWidth);
            return;
        }
예제 #6
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw line
        /// </summary>
        /// <param name="Line">Line object</param>
        ////////////////////////////////////////////////////////////////////
        public void DrawLine(
			LineD		Line
			)
        {
            DrawLine(Line.P1.X, Line.P1.Y, Line.P2.X, Line.P2.Y);
            return;
        }
예제 #7
0
        ////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draw heart
        /// </summary>
        /// <param name="CenterLine">Center line</param>
        /// <param name="PP">Paint operator</param>
        /// <remarks>
        /// <para>
        /// <a href="http://www.codeproject.com/Articles/570682/PDF-File-Writer-Csharp-Class-Library-Version#DrawHeart">For example of drawing heart see 3.10. Draw Heart</a>
        /// </para>
        /// </remarks>
        ////////////////////////////////////////////////////////////////////
        public void DrawHeart(
			LineD		CenterLine,
			PaintOp		PP
			)
        {
            // PI / 1.5 = 120 deg and PI / 2 = 90 deg
            DrawDoubleBezierPath(CenterLine, 1.0, Math.PI / 1.5, 1.0, 0.5 * Math.PI, PP);
            return;
        }
예제 #8
0
        /// <summary>
        /// PointD constructor
        /// </summary>
        /// <param name="L1">Line 1</param>
        /// <param name="L2">Line 2</param>
        public PointD(
			LineD	L1,
			LineD	L2
			)
        {
            Double L1DX = L1.DX;
            Double L1DY = L1.DY;
            Double L2DX = L2.DX;
            Double L2DY = L2.DY;

            Double Denom = L1DX * L2DY - L1DY * L2DX;
            if(Denom == 0.0)
            {
            X = Double.NaN;
            Y = Double.NaN;
            return;
            }

            X = (L1.DXY * L2.DX - L2.DXY * L1.DX) / Denom;
            Y = (L1.DXY * L2.DY - L2.DXY * L1.DY) / Denom;
            return;
        }
예제 #9
0
        /// <summary>
        /// Bezier constructor
        /// </summary>
        /// <param name="P1">P1</param>
        /// <param name="Factor2">Factor2</param>
        /// <param name="Alpha2">Alpha2</param>
        /// <param name="Factor3">Factor3</param>
        /// <param name="Alpha3">Alpha3</param>
        /// <param name="P4">P4</param>
        public BezierD(
			PointD	P1,
			Double	Factor2,
			Double	Alpha2,
			Double	Factor3,
			Double	Alpha3,
			PointD	P4
			)
        {
            // save two end points
            this.P1 = P1;
            this.P4 = P4;

            // distance between end points
            LineD Line = new LineD(P1, P4);
            Double Length = Line.Length;
            if(Length == 0)
            {
            P2 = P1;
            P3 = P4;
            return;
            }

            // angle of line between end points
            Double Alpha = Line.Alpha;

            this.P2 = new PointD(P1, Factor2 * Length, Alpha + Alpha2);
            this.P3 = new PointD(P4, Factor3 * Length, Alpha + Alpha3);
            return;
        }