コード例 #1
0
        /// <summary>
        /// This method creates the path geometry that represents the up continent in the planet.
        /// It demonstrates how to substitute clipping by intersecting.
        /// </summary>
        private void CreatePlanetUpPath()
        {
            // Since clip is required, we must draw to a temporary path, and then intersect it with the ellipse, and save the result in m_pPlanetUpPath.
            PathGeometry tempPath = this._d2DFactory.CreatePathGeometry();

            this._planetUpPath = this._d2DFactory.CreatePathGeometry();
            GeometrySink sink = tempPath.Open();

            sink.BeginFigure(new Point2F(0.0288963486137668f, 71.2923486227374f), FigureBegin.Filled);

            // The following AddBezier code are generated by the PowerShell script.
            sink.AddBezier(new BezierSegment(
                               new Point2F(-0.581304006712504f, 71.029349563583f),
                               new Point2F(8.52890129825862f, 88.2922878076214f),
                               new Point2F(22.0289091594593f, 91.7922752868622f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(35.5289170206599f, 95.292262766103f),
                               new Point2F(42.528921096838f, 64.2923736642557f),
                               new Point2F(42.528921096838f, 64.2923736642557f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(49.0289248818605f, 71.2923486227374f),
                               new Point2F(59.5289309961277f, 76.2923307359385f),
                               new Point2F(61.52893216075f, 94.7922645547829f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(63.5289333253723f, 113.292198373627f),
                               new Point2F(96.5289525416406f, 85.7922967510208f),
                               new Point2F(99.5289542885741f, 86.2922949623409f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(102.528956035508f, 86.792293173661f),
                               new Point2F(127.528970593286f, 111.792203739667f),
                               new Point2F(146.028981366043f, 106.792221626466f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(164.528992138799f, 101.792239513265f),
                               new Point2F(178.029f, 80.2923164264995f),
                               new Point2F(178.029f, 80.2923164264995f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(178.029f, 80.2923164264995f),
                               new Point2F(105.028957491285f, -94.2070593242214f),
                               new Point2F(0.0288963486137668f, 71.2923486227374f)));

            sink.EndFigure(FigureEnd.Closed);
            sink.Close();

            GeometrySink sink2 = this._planetUpPath.Open();
            // Create a clip ellipse.
            Ellipse         clip        = new Ellipse(new Point2F(87f, 121f), 100f, 100f);
            EllipseGeometry clipEllipse = this._d2DFactory.CreateEllipseGeometry(clip);

            // There's no direct support for clipping path in Direct2D. So we can intersect a path with its clip instead.
            tempPath.CombineWithGeometry(clipEllipse, CombineMode.Intersect, 0f, sink2);
            sink2.Close();
        }
コード例 #2
0
        /// <summary>
        /// This method creates the path geometry that represents the down continent in the planet.
        /// It demonstrates how to substitute clipping by intersecting.
        /// </summary>
        private void CreatePlanetDownPath()
        {
            // Since clip is required, we must draw to a temporary path, and then intersect it with the ellipse, and save the result in m_pPlanetUpPath.
            PathGeometry tempPath = this._d2DFactory.CreatePathGeometry();

            this._planetDownPath = this._d2DFactory.CreatePathGeometry();
            GeometrySink sink = tempPath.Open();

            sink.BeginFigure(new Point2F(0.0288963486137668f, 71.2923486227374f), FigureBegin.Filled);

            // The following AddBezier code are generated by the PowerShell script.
            sink.AddBezier(new BezierSegment(
                               new Point2F(0.715499175522696f, -0.486801532710843f),
                               new Point2F(26.1927417195169f, 14.0124923433061f),
                               new Point2F(48.6926998092458f, 17.5124667261123f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(71.1926578989747f, 21.0124411089184f),
                               new Point2F(94.1926150573642f, 39.512305703751f),
                               new Point2F(93.192616920043f, 53.512703231316f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(92.1926187827217f, 67.5126007625406f),
                               new Point2F(123.192561039681f, 82.5124909745669f),
                               new Point2F(123.192561039681f, 82.5124909745669f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(123.192561039681f, 82.5124909745669f),
                               new Point2F(134.192540550216f, 62.0126410181309f),
                               new Point2F(121.6925638337f, 45.0122654481606f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(109.192587117184f, 28.0123898745307f),
                               new Point2F(99.6926048126313f, 2.01258017368507f),
                               new Point2F(122.692561971021f, 21.5124374493193f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(145.69251912941f, 41.0122947249536f),
                               new Point2F(151.692507953338f, 62.5126373585318f),
                               new Point2F(149.192512610035f, 67.0126044221397f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(146.692517266732f, 71.5125714857476f),
                               new Point2F(159.192493983248f, 73.5125568473511f),
                               new Point2F(147.192516335392f, 84.5124763361704f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(135.192538687537f, 95.5123958249898f),
                               new Point2F(108.692588048523f, 102.012348250201f),
                               new Point2F(108.692588048523f, 102.012348250201f)));

            sink.AddBezier(new BezierSegment(
                               new Point2F(108.692588048523f, 102.012348250201f),
                               new Point2F(-5.30719960610358f, 132.012128674254f),
                               new Point2F(0.19280014914486f, 0.0125948120815593f)));

            sink.EndFigure(FigureEnd.Closed);
            sink.Close();

            GeometrySink sink2 = this._planetDownPath.Open();
            // Create a clip ellipse.
            Ellipse         clip        = new Ellipse(new Point2F(95f, 1f), 100f, 100f);
            EllipseGeometry clipEllipse = this._d2DFactory.CreateEllipseGeometry(clip);

            // There's no direct support for clipping path in Direct2D. So we can intersect a path with its clip instead.
            tempPath.CombineWithGeometry(clipEllipse, CombineMode.Intersect, 0f, sink2);
            sink2.Close();
        }