Пример #1
0
 protected override void Draw()
 {
     base.Draw();
     CCDrawingPrimitives.Begin();
     CCDrawingPrimitives.DrawSolidPoly(circleVertices, numberOfSegments, new CCColor4B(Color.R, Color.G, Color.B));
     CCDrawingPrimitives.End();
 }
Пример #2
0
        public override void Visit()
        {
            base.Visit();

            float   dx     = Position.X - AnchorPoint.X * ContentSize.Width;
            float   dy     = Position.Y - AnchorPoint.Y * ContentSize.Height;
            CCPoint offset = new CCPoint(dx, dy);

            CCPoint[] pv = new CCPoint[_polyVertices.Length];
            for (int i = 0; i < _polyVertices.Length; i++)
            {
                pv[i] = _polyVertices[i] + offset;
            }
            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawSolidPoly(pv, 4 * _cornerSegments + 1, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[0] + offset, _vertices[1] + offset, _vertices[2] + offset, _vertices[3] + offset, _cornerSegments, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[4] + offset, _vertices[5] + offset, _vertices[6] + offset, _vertices[7] + offset, _cornerSegments, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[8] + offset, _vertices[9] + offset, _vertices[10] + offset, _vertices[11] + offset, _cornerSegments, Color);
            CCDrawingPrimitives.DrawCubicBezier(_vertices[12] + offset, _vertices[13] + offset, _vertices[14] + offset, _vertices[15] + offset, _cornerSegments, Color);

            CCDrawingPrimitives.End();

            CCDrawingPrimitives.Begin();
            CCDrawingPrimitives.DrawLine(_vertices[3] + offset, _vertices[4] + offset, Color);
            CCDrawingPrimitives.DrawLine(_vertices[7] + offset, _vertices[8] + offset, Color);
            CCDrawingPrimitives.DrawLine(_vertices[11] + offset, _vertices[12] + offset, Color);
            CCDrawingPrimitives.DrawLine(_vertices[15] + offset, _vertices[0] + offset, Color);

            CCDrawingPrimitives.End();
        }
Пример #3
0
        public override void Draw()
        {
            base.Draw();

            CCApplication app = CCApplication.SharedApplication;
            CCSize        s   = CCDirector.SharedDirector.WinSize;

            CCDrawingPrimitives.Begin();

            // draw a simple line
            CCDrawingPrimitives.DrawLine(new CCPoint(0, 0), new CCPoint(s.Width, s.Height),
                                         new CCColor4B(255, 255, 255, 255));

            // line: color, width, aliased
            CCDrawingPrimitives.DrawLine(new CCPoint(0, s.Height), new CCPoint(s.Width, 0),
                                         new CCColor4B(255, 0, 0, 255));

            // draw big point in the center
            CCDrawingPrimitives.DrawPoint(new CCPoint(s.Width / 2, s.Height / 2), 64, new CCColor4B(0, 0, 255, 128));

            // draw 4 small points
            CCPoint[] points = { new CCPoint(60, 60), new CCPoint(70, 70), new CCPoint(60, 70), new CCPoint(70, 60) };
            CCDrawingPrimitives.DrawPoints(points, 4, 4, new CCColor4B(0, 255, 255, 255));

            // draw a green circle with 10 segments
            CCDrawingPrimitives.DrawCircle(new CCPoint(s.Width / 2, s.Height / 2), 100, 0, 10, false,
                                           new CCColor4B(0, 255, 0, 255));

            // draw a green circle with 50 segments with line to center
            CCDrawingPrimitives.DrawCircle(new CCPoint(s.Width / 2, s.Height / 2), 50, CCMacros.CCDegreesToRadians(90),
                                           50, true, new CCColor4B(0, 255, 255, 255));


            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawArc(new CCRect(200, 200, 100, 200), 0, 180,
                                        new CCColor4B(Microsoft.Xna.Framework.Color.AliceBlue));

            // draw an ellipse within rectangular region
            CCDrawingPrimitives.DrawEllipse(new CCRect(500, 200, 100, 200), new CCColor4B(255, 0, 0, 255));

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(350, 0, 100, 100), 20, 100,
                                        new CCColor4B(Microsoft.Xna.Framework.Color.AliceBlue));

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(347, -5, 100, 100), 120, 260,
                                        new CCColor4B(Microsoft.Xna.Framework.Color.Aquamarine));

            // open yellow poly
            CCPoint[] vertices =
            {
                new CCPoint(0,  0), new CCPoint(50, 50), new CCPoint(100, 50), new CCPoint(100, 100),
                new CCPoint(50, 100)
            };
            CCDrawingPrimitives.DrawPoly(vertices, 5, false, new CCColor4B(255, 255, 0, 255));

            // filled poly
            CCPoint[] filledVertices =
            {
                new CCPoint(0,  120), new CCPoint(50, 120), new CCPoint(50, 170),
                new CCPoint(25, 200), new CCPoint(0, 170)
            };
            CCDrawingPrimitives.DrawSolidPoly(filledVertices, 5, new CCColor4B(128, 128, 255, 255));

            // closed purble poly
            CCPoint[] vertices2 = { new CCPoint(30, 130), new CCPoint(30, 230), new CCPoint(50, 200) };
            CCDrawingPrimitives.DrawPoly(vertices2, 3, true, new CCColor4B(255, 0, 255, 255));

            // draw quad bezier path
            CCDrawingPrimitives.DrawQuadBezier(new CCPoint(0, s.Height),
                                               new CCPoint(s.Width / 2, s.Height / 2),
                                               new CCPoint(s.Width, s.Height),
                                               50,
                                               new CCColor4B(255, 0, 255, 255));

            // draw cubic bezier path
            CCDrawingPrimitives.DrawCubicBezier(new CCPoint(s.Width / 2, s.Height / 2),
                                                new CCPoint(s.Width / 2 + 30, s.Height / 2 + 50),
                                                new CCPoint(s.Width / 2 + 60, s.Height / 2 - 50),
                                                new CCPoint(s.Width, s.Height / 2), 100,
                                                new CCColor4B(255, 0, 255, 255));

            //draw a solid polygon
            CCPoint[] vertices3 =
            {
                new CCPoint(60, 160), new CCPoint(70, 190), new CCPoint(100, 190),
                new CCPoint(90, 160)
            };
            CCDrawingPrimitives.DrawSolidPoly(vertices3, 4, new CCColor4B(255, 255, 0, 255));

            CCDrawingPrimitives.End();
        }
Пример #4
0
        protected override void Draw()
        {
            base.Draw();

            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            var visibleRect = VisibleBoundsWorldspace;

            CCDrawingPrimitives.Begin();


            // *NOTE* Using the Director.ContentScaleFactor for now until we work something out with the initialization
            // CCDrawPriitives should be able to do this converstion themselves.

            // draw a simple line
            // The default state is:
            // Line Width: 1
            // color: 255,255,255,255 (white, non-transparent)
            // Anti-Aliased
            //  glEnable(GL_LINE_SMOOTH);
            CCDrawingPrimitives.LineWidth = 1;
            CCDrawingPrimitives.DrawLine(visibleRect.LeftBottom(), visibleRect.RightTop());

            // line: color, width, aliased
            CCDrawingPrimitives.LineWidth = 5;
            CCDrawingPrimitives.DrawColor = CCColor4B.Red;
            CCDrawingPrimitives.DrawLine(visibleRect.LeftTop(), visibleRect.RightBottom());

            // TIP:
            // If you are going to use always thde same color or width, you don't
            // need to call it before every draw
            //

            // draw big point in the center
            CCDrawingPrimitives.PointSize = 64;
            CCDrawingPrimitives.DrawColor = new CCColor4B(0, 0, 255, 128);
            CCDrawingPrimitives.DrawPoint(visibleRect.Center());

            // draw 4 small points
            CCPoint[] points = { new CCPoint(60, 60), new CCPoint(70, 70), new CCPoint(60, 70), new CCPoint(70, 60) };

            CCDrawingPrimitives.PointSize = 8;
            CCDrawingPrimitives.DrawColor = new CCColor4B(0, 255, 255, 255);
            CCDrawingPrimitives.DrawPoints(points);

            // draw a green circle with 10 segments
            CCDrawingPrimitives.LineWidth = 16;
            CCDrawingPrimitives.DrawColor = CCColor4B.Green;
            CCDrawingPrimitives.DrawCircle(visibleRect.Center, 100, 0, 10, false);


            // draw a green circle with 50 segments with line to center
            CCDrawingPrimitives.LineWidth = 2;
            CCDrawingPrimitives.DrawColor = new CCColor4B(0, 255, 255, 255);
            CCDrawingPrimitives.DrawCircle(visibleRect.Center, 50, CCMacros.CCDegreesToRadians(45), 50, true);


            // draw a pink solid circle with 50 segments
            CCDrawingPrimitives.LineWidth = 2;
            CCDrawingPrimitives.DrawColor = new CCColor4B(255, 0, 255, 255);
            CCDrawingPrimitives.DrawSolidCircle(visibleRect.Center + new CCPoint(140, 0), 40, CCMacros.CCDegreesToRadians(90), 50);


            // draw an arc within rectangular region
            CCDrawingPrimitives.LineWidth = 5;
            CCDrawingPrimitives.DrawArc(new CCRect(200, 100, 100, 200), 0, 180, CCColor4B.AliceBlue);

            // draw an ellipse within rectangular region
            CCDrawingPrimitives.DrawEllipse(new CCRect(100, 100, 100, 200), CCColor4B.Red);

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(350, 0, 100, 100), 20, 100, CCColor4B.AliceBlue);

            // draw an arc within rectangular region
            CCDrawingPrimitives.DrawPie(new CCRect(347, -5, 100, 100), 120, 260, CCColor4B.Aquamarine);

            // open yellow poly
            CCPoint[] vertices =
            {
                new CCPoint(0,  0), new CCPoint(50, 50), new CCPoint(100, 50), new CCPoint(100, 100),
                new CCPoint(50, 100)
            };
            CCDrawingPrimitives.LineWidth = 10;
            CCDrawingPrimitives.DrawColor = CCColor4B.Yellow;
            CCDrawingPrimitives.DrawPoly(vertices, 5, false, new CCColor4B(255, 255, 0, 255));


            // filled poly
            CCDrawingPrimitives.LineWidth = 1;
            CCPoint[] filledVertices =
            {
                new CCPoint(0,  120), new CCPoint(50, 120), new CCPoint(50, 170),
                new CCPoint(25, 200), new CCPoint(0, 170)
            };
            CCDrawingPrimitives.DrawSolidPoly(filledVertices, new CCColor4F(0.5f, 0.5f, 1, 1));

            // closed purple poly
            CCDrawingPrimitives.LineWidth = 2;
            CCDrawingPrimitives.DrawColor = new CCColor4B(255, 0, 255, 255);
            CCPoint[] vertices2 = { new CCPoint(30, 130), new CCPoint(30, 230), new CCPoint(50, 200) };
            CCDrawingPrimitives.DrawPoly(vertices2, true);

            // draw quad bezier path
            CCDrawingPrimitives.DrawQuadBezier(new CCPoint(0, size.Height),
                                               visibleRect.Center,
                                               (CCPoint)visibleRect.Size,
                                               50,
                                               new CCColor4B(255, 0, 255, 255));

            // draw cubic bezier path
            CCDrawingPrimitives.DrawCubicBezier(visibleRect.Center,
                                                new CCPoint(size.Width / 2 + 30, size.Height / 2 + 50),
                                                new CCPoint(size.Width / 2 + 60, size.Height / 2 - 50),
                                                new CCPoint(size.Width, size.Height / 2), 100);

            //draw a solid polygon
            CCPoint[] vertices3 =
            {
                new CCPoint(60, 160), new CCPoint(70, 190), new CCPoint(100, 190),
                new CCPoint(90, 160)
            };
            CCDrawingPrimitives.DrawSolidPoly(vertices3, 4, new CCColor4F(1, 1, 0, 1));

            CCDrawingPrimitives.End();
        }