Exemplo n.º 1
0
 public Background(CCSize size, CCColor4B color)
 {
     Color = new CCColor3B(color);
     Opacity = color.A;
     AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
        /*
         *  TL    TR
         *   0----1 0,1,2,3 = index offsets for vertex indices
         *   |   /|
         *   |  / |
         *   | /  |
         *   |/   |
         *   2----3
         *  BL    BR
         */
        void GenerateGradient(CCSize textureSizeInPixels)
        {
            var gradientNode = new CCDrawNode();

            var gradientAlpha = new CCColor4B(0, 0, 0,(byte)(0.7f * 255f));
            CCV3F_C4B[] vertices = new CCV3F_C4B[6];

            // Left triangle TL - 0
            vertices[0].Vertices = new CCVertex3F(0, textureSizeInPixels.Height, 0);
            vertices[0].Colors = CCColor4B.Transparent;

            // Left triangle BL - 2
            vertices[1].Vertices = new CCVertex3F(0, 0, 0);
            vertices[1].Colors = gradientAlpha;

            // Left triangle TR - 1
            vertices[2].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0);
            vertices[2].Colors = CCColor4B.Transparent;

            // Right triangle BL - 2
            vertices[3].Vertices = new CCVertex3F(0, 0, 0);
            vertices[3].Colors = gradientAlpha;

            // Right triangle BR - 3
            vertices[4].Vertices = new CCVertex3F(textureSizeInPixels.Width, 0, 0);
            vertices[4].Colors = gradientAlpha;

            // Right triangle TR - 1
            vertices[5].Vertices = new CCVertex3F(textureSizeInPixels.Width, textureSizeInPixels.Height, 0);
            vertices[5].Colors = CCColor4B.Transparent;

            gradientNode.DrawTriangleList(vertices);

            gradientNode.Visit();
        }
Exemplo n.º 3
0
 public AlignmentPanel(CCSize size, CCColor4B color)
 {
     Color = new CCColor3B(color);
     Opacity = color.A;
     //AnchorPoint = CCPoint.AnchorMiddle;
     ContentSize = size;
 }
        public SpriteWithColor(CCColor4B bgColor, CCSize textureSizeInPixels) : base ()
        {
            // 1: Create new CCRenderTexture
            CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);

            // 2: Call CCRenderTexture:begin
            rt.BeginWithClear(bgColor);

            // 3: Draw into the texture
            // You'll add this later
            GenerateGradient(textureSizeInPixels);


            var noise = new CCSprite("images/Noise.png");
            noise.AnchorPoint = CCPoint.AnchorLowerLeft;
            noise.Position = CCPoint.Zero;
            noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
            noise.Texture.SamplerState = Microsoft.Xna.Framework.Graphics.SamplerState.LinearWrap;

            // To get the linear wrap to work correctly we have to set the TextureRectInPixels as well as ContentSize
            noise.TextureRectInPixels = new CCRect(0, 0, textureSizeInPixels.Width, textureSizeInPixels.Height);
            noise.ContentSize = noise.TextureRectInPixels.Size;
            noise.Visit();

            // 4: Call CCRenderTexture:end
            rt.End();

            this.Texture = rt.Texture;

        }
Exemplo n.º 5
0
        internal static CCTexture2D CreateNativeLabel(string text, CCSize dimensions, CCTextAlignment hAlignment,
		                                   CCVerticalTextAlignment vAlignment, string fontName,
		                                   float fontSize, CCColor4B textColor)
		{

		    if (string.IsNullOrEmpty(text))
		    {
		        return new CCTexture2D();
		    }

		    var font = CreateFont (fontName, fontSize);

            if (dimensions.Equals(CCSize.Zero))
            {
                CreateBitmap(1, 1);

                var ms = _graphics.MeasureString(text, font);
                
                dimensions.Width = ms.Width;
                dimensions.Height = ms.Height;
            }

            CreateBitmap((int)dimensions.Width, (int)dimensions.Height);

            var stringFormat = new StringFormat();

		    switch (hAlignment)
		    {
		        case CCTextAlignment.Left:
                    stringFormat.Alignment = StringAlignment.Near;
		            break;
		        case CCTextAlignment.Center:
                    stringFormat.Alignment = StringAlignment.Center;
		            break;
		        case CCTextAlignment.Right:
                    stringFormat.Alignment = StringAlignment.Far;
		            break;
		    }

		    switch (vAlignment)
		    {
		        case CCVerticalTextAlignment.Top:
        		    stringFormat.LineAlignment = StringAlignment.Near;
		            break;
		        case CCVerticalTextAlignment.Center:
        		    stringFormat.LineAlignment = StringAlignment.Center;
		            break;
		        case CCVerticalTextAlignment.Bottom:
        		    stringFormat.LineAlignment = StringAlignment.Far;
		            break;
		    }

            _graphics.DrawString(text, font, _brush, new RectangleF(0, 0, dimensions.Width, dimensions.Height), stringFormat);
            _graphics.Flush();

            var texture = new CCTexture2D(SaveToStream(), CCSurfaceFormat.Bgra4444);

			return texture;
		}
Exemplo n.º 6
0
 public static CCV3F_C4B ToVectorC4B(this b2Vec2 vec, CCColor4B color, int PTMRatio)
 {
     var v3f_c4b = new CCV3F_C4B();
     v3f_c4b.Vertices.X = vec.x * PTMRatio;
     v3f_c4b.Vertices.Y = vec.y * PTMRatio;
     v3f_c4b.Colors = color;
     return v3f_c4b;
 }
Exemplo n.º 7
0
        public override void DrawSolidPolygon(Box2D.Common.b2Vec2[] vertices, int vertexCount, Box2D.Common.b2Color color)
        {
            CCPoint[] verticesToPoint = new CCPoint[vertexCount];
            CCColor4B Color = new CCColor4B (color.r, color.g, color.b, 255);
            for (int i = 0; i < vertexCount; i++) {
                verticesToPoint [i] = new CCPoint (vertices [i].x * 50f, vertices [i].y * 50f);
            }

            DrawNode.DrawPolygon (verticesToPoint, vertexCount, Color, 3f, Color);
        }
Exemplo n.º 8
0
 public Ball(float x, float y, float r, CCColor4B c)
 {
     this.x     = x;
     this.y     = y;
     this.r     = r;
     this.color = c;
     location   = new CCPoint (x , y);
     circle     = new CCDrawNode ();
     drawCircle ();
 }
        /*
         *  TL    TR
         *   0----1 0,1,2,3 = index offsets for vertex indices
         *   |   /| 
         *   |  / |
         *   | /  |
         *   |/   |
         *   2----3
         *  BL    BR
         */
        void GenerateStripes (CCSize textureSizeInPixels, CCColor4B c2, int numberOfStripes)
        {
            var gradientNode = new CCDrawNode();

            // Layer 1: Stripes
            CCV3F_C4B[] vertices = new CCV3F_C4B[numberOfStripes*6];

            var textureWidth = textureSizeInPixels.Width;
            var textureHeight = textureSizeInPixels.Height;

            int nVertices = 0;
            float x1 = -textureHeight;
            float x2;
            float y1 = textureHeight;
            float y2 = 0;
            float dx = textureWidth / numberOfStripes * 2;
            float stripeWidth = dx/2;

            for (int i=0; i<numberOfStripes; i++) 
            {

                x2 = x1 + textureHeight;

                // Left triangle TL - 0
                vertices[nVertices].Vertices = new CCVertex3F(x1, y1, 0);
                vertices[nVertices++].Colors = c2;

                // Left triangle BL - 2
                vertices[nVertices].Vertices = new CCVertex3F(x1+stripeWidth, y1, 0);
                vertices[nVertices++].Colors = c2;

                // Left triangle TR - 1
                vertices[nVertices].Vertices = new CCVertex3F(x2, y2, 0);
                vertices[nVertices++].Colors = c2;

                // Right triangle BL - 2
                vertices[nVertices].Vertices = vertices[nVertices-2].Vertices;
                vertices[nVertices++].Colors = c2;

                // Right triangle BR - 3
                vertices[nVertices].Vertices = vertices[nVertices-2].Vertices;
                vertices[nVertices++].Colors = c2;

                // Right triangle TR - 1
                vertices[nVertices].Vertices = new CCVertex3F(x2+stripeWidth, y2, 0);
                vertices[nVertices++].Colors = c2;

                x1 += dx;
            }

            gradientNode.DrawTriangleList(vertices);

            gradientNode.Visit();

        }
		private void CreateBitmap(int width, int height)
		{
//			if (_bitmap == null || (_bitmap.Width < width || _bitmap.Height < height))
//			{

            _bitmap = CCLabelUtilities.CreateBitmap (width, height);
			//}

			//if (_brush == null)
			//{
            _brush = CCColor4B.White;
			//}
		}
Exemplo n.º 11
0
        public static void DrawPoint(CCPoint p, float size, CCColor4B color)
        {
            var verts = new CCPoint[4];

            float hs = size / 2.0f;

            verts[0] = p + new CCPoint(-hs, -hs);
            verts[1] = p + new CCPoint(hs, -hs);
            verts[2] = p + new CCPoint(hs, hs);
            verts[3] = p + new CCPoint(-hs, hs);

            DrawPoly(verts, 4, false, true, color);
        }
Exemplo n.º 12
0
        private void RefreshColor()
        {
            BackgroundNode.Cleanup();

            CCColor4B CurrColor = new CCColor4B();
            if (Status == ButtonStatus.Pressed)
            {
                CurrColor = ClickedColor;
            }
            else
            {
                CurrColor = NormalColor;
            }

            BackgroundNode.DrawRect(new CCRect(0, 0, ContentSize.Width, ContentSize.Height), CurrColor);
        }
Exemplo n.º 13
0
        public void DrawCircle(CCPoint center, float radius, int segments, CCColor4B color)
        {
            var cl = color;

            float theta = MathHelper.Pi * 2.0f / segments;
            float tangetial_factor = (float)Math.Tan(theta);   //calculate the tangential factor 

            float radial_factor = (float)Math.Cos(theta);   //calculate the radial factor 

            float x = radius;  //we start at angle = 0 
            float y = 0;

            var vert1 = new CCV3F_C4B(CCVertex3F.Zero, cl);
            float tx = 0;
            float ty = 0;

            for (int i = 0; i < segments; i++)
            {

                vert1.Vertices.X = x + center.X;
                vert1.Vertices.Y = y + center.Y;
                AddLineVertex(vert1); // output vertex

                //calculate the tangential vector 
                //remember, the radial vector is (x, y) 
                //to get the tangential vector we flip those coordinates and negate one of them 
                tx = -y;
                ty = x;

                //add the tangential vector 
                x += tx * tangetial_factor;
                y += ty * tangetial_factor;

                //correct using the radial factor 
                x *= radial_factor;
                y *= radial_factor;

                vert1.Vertices.X = x + center.X;
                vert1.Vertices.Y = y + center.Y;
                AddLineVertex(vert1); // output vertex

            }

            dirty = true;

        }
Exemplo n.º 14
0
        protected void Draw()
        {
            CCColor4B color = new CCColor4B(1.0f, 1.0f, 1.0f, 1.0f);
            

            switch (_lineType)
            {
                case lineTypes.LINE_NONE:
                    break;
                case lineTypes.LINE_TEMP:
                    drawNode.DrawLine(_tip, _pivot, color);
                    drawNode.DrawCircle(_pivot, 10, 10, color);
                    break;

                case lineTypes.LINE_DASHED:
                    drawNode.DrawCircle(_pivot, 10, 10, color);
                    int segments = (int)(_lineLength / (_dash + _dashSpace));
                    float t = 0.0f;
                    float x_;
                    float y_;

                    for (int i = 0; i < segments + 1; i++)
                    {
                        x_ = _pivot.X + t * (_tip.X - _pivot.X);
                        y_ = _pivot.Y + t * (_tip.Y - _pivot.Y);
                        drawNode.DrawCircle(new CCPoint(x_, y_), 4, 6, color);
                        t += (float)1 / segments;
                    }
                    break;
            }

            //draw energy bar
            color = new CCColor4B(0.0f, 0.0f, 0.0f, 1.0f);

            drawNode.DrawLine(
                new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
                new CCPoint(_energyLineX, _screenSize.Height * 0.9f),
                color);
            color = new CCColor4B(1.0f, 0.5f, 0.0f, 1.0f);
            drawNode.DrawLine(
                new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
                new CCPoint(_energyLineX, _screenSize.Height * 0.1f + _energy * _energyHeight),
                color);
        }
        public StripeWithColor(CCColor4B c1, CCColor4B c2, CCSize textureSizeInPixels, int nStripes) : base ()
        {
            // 1: Create new CCRenderTexture
            CCRenderTexture rt = new CCRenderTexture(textureSizeInPixels, textureSizeInPixels);

            // 2: Call CCRenderTexture:begin
            rt.BeginWithClear(c1);

            // 3: Draw into the texture
            // You'll add this later
            GenerateStripes(textureSizeInPixels, c2, nStripes);

            var noise = new CCSprite("images/Noise.png");
            noise.AnchorPoint = CCPoint.AnchorLowerLeft;
            noise.BlendFunc = new CCBlendFunc(CCOGLES.GL_DST_COLOR, CCOGLES.GL_ZERO);
            noise.Visit();

            // 4: Call CCRenderTexture:end
            rt.End();

            this.Texture = rt.Texture;
        }
Exemplo n.º 16
0
 public void Clear(CCColor4B color, float depth)
 {
     Clear(color, depth, 0);
 }
Exemplo n.º 17
0
        // Used for drawing line caps
        public void DrawSolidArc(CCPoint pos, float radius, float startAngle, float sweepAngle, CCColor4B color)
        {
            var cl = color.ToColor();

            int segments = (int)(10 * (float)Math.Sqrt(radius));  //<- Let's try to guess at # segments for a reasonable smoothness

            float theta            = sweepAngle / (segments - 1); // MathHelper.Pi * 2.0f / segments;
            float tangetial_factor = (float)Math.Tan(theta);      //calculate the tangential factor

            float radial_factor = (float)Math.Cos(theta);         //calculate the radial factor

            float x = radius * (float)Math.Cos(startAngle);       //we now start at the start angle
            float y = radius * (float)Math.Sin(startAngle);

            var   verticeCenter = new VertexPositionColor(new Vector3(pos.X, pos.Y, 0), cl);
            var   vert1         = new VertexPositionColor(Vector3.Zero, cl);
            float tx            = 0;
            float ty            = 0;

            for (int i = 0; i < segments - 1; i++)
            {
                triangleVertices.Add(verticeCenter);

                vert1.Position.X = x + pos.X;
                vert1.Position.Y = y + pos.Y;
                triangleVertices.Add(vert1); // output vertex

                //calculate the tangential vector
                //remember, the radial vector is (x, y)
                //to get the tangential vector we flip those coordinates and negate one of them
                tx = -y;
                ty = x;

                //add the tangential vector
                x += tx * tangetial_factor;
                y += ty * tangetial_factor;

                //correct using the radial factor
                x *= radial_factor;
                y *= radial_factor;

                vert1.Position.X = x + pos.X;
                vert1.Position.Y = y + pos.Y;
                triangleVertices.Add(vert1); // output vertex
            }

            dirty = true;
        }
Exemplo n.º 18
0
 public CCV3F_C4B(CCPoint position, CCColor4B color)
 {
     this.Vertices = CCVertex3F.Zero;
     this.Vertices.X = position.X;
     this.Vertices.Y = position.Y;
     Colors = color;
 }
Exemplo n.º 19
0
 public CCV2F_C4B_T2F()
 {
     Vertices = new CCVertex2F();
     Colors = new CCColor4B();
     TexCoords = new CCTex2F();
 }
Exemplo n.º 20
0
 public CCColor4F(CCColor4B color4B) : this(color4B.R / 255.0f, color4B.G / 255.0f, color4B.B / 255.0f, color4B.A / 255.0f)
 {
 }
Exemplo n.º 21
0
 public bool Equals(CCColor4B other)        
 {            
     return this == other;       
 } 
Exemplo n.º 22
0
		public static void DrawPoints(CCPoint[] points, int numberOfPoints, float size, CCColor4B color)
        {
            for (int i = 0; i < numberOfPoints; i++)
            {
                DrawPoint(points[i], size, color);
            }
        }
        internal static void NativeDrawString(CGBitmapContext bitmapContext, string s, CTFont font, CCColor4B brush, RectangleF layoutRectangle)
        {
            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            if (s == null || s.Length == 0)
            {
                return;
            }

            bitmapContext.ConcatCTM(bitmapContext.GetCTM().Invert());

            // This is not needed here since the color is set in the attributed string.
            //bitmapContext.SetFillColor(brush.R/255f, brush.G/255f, brush.B/255f, brush.A/255f);

            // I think we only Fill the text with no Stroke surrounding
            //bitmapContext.SetTextDrawingMode(CGTextDrawingMode.Fill);

            var attributedString = buildAttributedString(s, font, brush);

            // Work out the geometry
            RectangleF insetBounds = layoutRectangle;

            PointF textPosition = new PointF(insetBounds.X,
                                             insetBounds.Y);

            float boundsWidth = insetBounds.Width;

            // Calculate the lines
            int start  = 0;
            int length = attributedString.Length;

            var typesetter = new CTTypesetter(attributedString);

            float baselineOffset = 0;

            // First we need to calculate the offset for Vertical Alignment if we
            // are using anything but Top
            if (vertical != CCVerticalTextAlignment.Top)
            {
                while (start < length)
                {
                    int count = typesetter.SuggestLineBreak(start, boundsWidth);
                    var line  = typesetter.GetLine(new NSRange(start, count));

                    // Create and initialize some values from the bounds.
                    float ascent;
                    float descent;
                    float leading;
                    line.GetTypographicBounds(out ascent, out descent, out leading);
                    baselineOffset += (float)Math.Ceiling(ascent + descent + leading + 1);                      // +1 matches best to CTFramesetter's behavior
                    line.Dispose();
                    start += count;
                }
            }

            start = 0;

            while (start < length && textPosition.Y < insetBounds.Bottom)
            {
                // Now we ask the typesetter to break off a line for us.
                // This also will take into account line feeds embedded in the text.
                //  Example: "This is text \n with a line feed embedded inside it"
                int count = typesetter.SuggestLineBreak(start, boundsWidth);
                var line  = typesetter.GetLine(new NSRange(start, count));

                // Create and initialize some values from the bounds.
                float ascent;
                float descent;
                float leading;
                line.GetTypographicBounds(out ascent, out descent, out leading);

                // Calculate the string format if need be
                var penFlushness = 0.0f;

                if (horizontal == CCTextAlignment.Right)
                {
                    penFlushness = (float)line.GetPenOffsetForFlush(1.0f, boundsWidth);
                }
                else if (horizontal == CCTextAlignment.Center)
                {
                    penFlushness = (float)line.GetPenOffsetForFlush(0.5f, boundsWidth);
                }

                // initialize our Text Matrix or we could get trash in here
                var textMatrix = CGAffineTransform.MakeIdentity();

                if (vertical == CCVerticalTextAlignment.Top)
                {
                    textMatrix.Translate(penFlushness, insetBounds.Height - textPosition.Y - (float)Math.Floor(ascent - 1));
                }
                if (vertical == CCVerticalTextAlignment.Center)
                {
                    textMatrix.Translate(penFlushness, ((insetBounds.Height / 2) + (baselineOffset / 2)) - textPosition.Y - (float)Math.Floor(ascent - 1));
                }
                if (vertical == CCVerticalTextAlignment.Bottom)
                {
                    textMatrix.Translate(penFlushness, baselineOffset - textPosition.Y - (float)Math.Floor(ascent - 1));
                }

                // Set our matrix
                bitmapContext.TextMatrix = textMatrix;

                // and draw the line
                line.Draw(bitmapContext);

                // Move the index beyond the line break.
                start          += count;
                textPosition.Y += (float)Math.Ceiling(ascent + descent + leading + 1);                 // +1 matches best to CTFramesetter's behavior
                line.Dispose();
            }
        }
Exemplo n.º 24
0
 public void BeginWithClear(CCColor4B clearColor, float depth = 1.0f, int stencil = 0)
 {
     ClearColor = clearColor;
     Begin();
 }
Exemplo n.º 25
0
        void UpdateQuad(ref CCV3F_C4B_T2F_Quad quad, ref CCParticleBase particle)
        {
            CCPoint newPosition;

            if (PositionType == CCPositionType.Free || PositionType == CCPositionType.Relative)
            {
                newPosition.X = particle.Position.X - (currentPosition.X - particle.StartPosition.X);
                newPosition.Y = particle.Position.Y - (currentPosition.Y - particle.StartPosition.Y);
            }
            else
            {
                newPosition = particle.Position;
            }

            // translate newPos to correct position, since matrix transform isn't performed in batchnode
            // don't update the particle with the new position information, it will interfere with the radius and tangential calculations
            if (BatchNode != null)
            {
                newPosition.X += Position.X;
                newPosition.Y += Position.Y;
            }

            CCColor4B color = new CCColor4B();

            if (OpacityModifyRGB)
            {
                color.R = (byte)(particle.Color.R * particle.Color.A * 255);
                color.G = (byte)(particle.Color.G * particle.Color.A * 255);
                color.B = (byte)(particle.Color.B * particle.Color.A * 255);
                color.A = (byte)(particle.Color.A * 255);
            }
            else
            {
                color.R = (byte)(particle.Color.R * 255);
                color.G = (byte)(particle.Color.G * 255);
                color.B = (byte)(particle.Color.B * 255);
                color.A = (byte)(particle.Color.A * 255);
            }

            quad.BottomLeft.Colors  = color;
            quad.BottomRight.Colors = color;
            quad.TopLeft.Colors     = color;
            quad.TopRight.Colors    = color;

            // vertices
            float size_2 = particle.Size / 2;

            if (particle.Rotation != 0.0)
            {
                float x1 = -size_2;
                float y1 = -size_2;

                float x2 = size_2;
                float y2 = size_2;
                float x  = newPosition.X;
                float y  = newPosition.Y;

                float r  = -CCMathHelper.ToRadians(particle.Rotation);
                float cr = CCMathHelper.Cos(r);
                float sr = CCMathHelper.Sin(r);
                float ax = x1 * cr - y1 * sr + x;
                float ay = x1 * sr + y1 * cr + y;
                float bx = x2 * cr - y1 * sr + x;
                float by = x2 * sr + y1 * cr + y;
                float cx = x2 * cr - y2 * sr + x;
                float cy = x2 * sr + y2 * cr + y;
                float dx = x1 * cr - y2 * sr + x;
                float dy = x1 * sr + y2 * cr + y;

                // bottom-left
                quad.BottomLeft.Vertices.X = ax;
                quad.BottomLeft.Vertices.Y = ay;

                // bottom-right vertex:
                quad.BottomRight.Vertices.X = bx;
                quad.BottomRight.Vertices.Y = by;

                // top-left vertex:
                quad.TopLeft.Vertices.X = dx;
                quad.TopLeft.Vertices.Y = dy;

                // top-right vertex:
                quad.TopRight.Vertices.X = cx;
                quad.TopRight.Vertices.Y = cy;
            }
            else
            {
                // bottom-left vertex:
                quad.BottomLeft.Vertices.X = newPosition.X - size_2;
                quad.BottomLeft.Vertices.Y = newPosition.Y - size_2;

                // bottom-right vertex:
                quad.BottomRight.Vertices.X = newPosition.X + size_2;
                quad.BottomRight.Vertices.Y = newPosition.Y - size_2;

                // top-left vertex:
                quad.TopLeft.Vertices.X = newPosition.X - size_2;
                quad.TopLeft.Vertices.Y = newPosition.Y + size_2;

                // top-right vertex:
                quad.TopRight.Vertices.X = newPosition.X + size_2;
                quad.TopRight.Vertices.Y = newPosition.Y + size_2;
            }
        }
Exemplo n.º 26
0
 public void Clear(CCColor4B color)
 {
     Clear(color, 1.0f);
 }
Exemplo n.º 27
0
 public static void DrawPoints(CCPoint[] points, float size, CCColor4B color)
 {
     DrawPoints(points, points.Length, size, color);
 }
Exemplo n.º 28
0
 public void DrawPolygon(CCPoint[] verts, int count, CCColor4B fillColor, float borderWidth,
                         CCColor4B borderColor)
 {
     DrawPolygon(verts, count, new CCColor4F(fillColor), borderWidth, new CCColor4F(borderColor));
 }
		protected override void Draw()
		{
			base.Draw();

			CCColor4B color = new CCColor4B(1.0f, 1.0f, 1.0f, 1.0f);

			CCDrawingPrimitives.Begin();

			switch (_lineType)
			{
				case lineTypes.LINE_NONE:
					break;
				case lineTypes.LINE_TEMP:

					//CCDrawingPrimitives.Begin();
					CCDrawingPrimitives.DrawLine(_tip, _pivot, color);
					CCDrawingPrimitives.DrawCircle(_pivot, 10, CCMathHelper.ToRadians(360), 10, false, color);
					//CCDrawingPrimitives.End();

					break;

				case lineTypes.LINE_DASHED:

					//CCDrawingPrimitives.Begin();
					CCDrawingPrimitives.DrawCircle(_pivot, 10, (float)Math.PI, 10, false, color);
					//CCDrawingPrimitives.End();

					int segments = (int)(_lineLength / (_dash + _dashSpace));

					float t = 0.0f;
					float x_;
					float y_;

					for (int i = 0; i < segments + 1; i++)
					{

						x_ = _pivot.X + t * (_tip.X - _pivot.X);
						y_ = _pivot.Y + t * (_tip.Y - _pivot.Y);

						//CCDrawingPrimitives.Begin();
						CCDrawingPrimitives.DrawCircle(new CCPoint(x_, y_), 4, (float)Math.PI, 6, false, color);
						//CCDrawingPrimitives.End();

						t += (float)1 / segments;
					}
					break;
			}

			//draw energy bar
			color = new CCColor4B(0.0f, 0.0f, 0.0f, 1.0f);

			CCDrawingPrimitives.DrawLine(
				new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
				new CCPoint(_energyLineX, _screenSize.Height * 0.9f),
				color);

			color = new CCColor4B(1.0f, 0.5f, 0.0f, 1.0f);

			CCDrawingPrimitives.DrawLine(
				new CCPoint(_energyLineX, _screenSize.Height * 0.1f),
				new CCPoint(_energyLineX, _screenSize.Height * 0.1f + _energy * _energyHeight),
				color);

			CCDrawingPrimitives.End();
		}
Exemplo n.º 30
0
 public CCLayerColor(CCColor4B color) : this(CCSize.Zero, color)
 {
 }
Exemplo n.º 31
0
        public static CCColor4B Lerp(CCColor4B value1, CCColor4B value2, float amount)
        {
            CCColor4B color = new CCColor4B();

            color.A = (byte)(value1.A + ((value2.A - value1.A) * amount));
            color.R = (byte)(value1.R + ((value2.R - value1.R) * amount));
            color.G = (byte)(value1.G + ((value2.G - value1.G) * amount));
            color.B = (byte)(value1.B + ((value2.B - value1.B) * amount));

            return color;
        }
Exemplo n.º 32
0
 public CCLayerColor(CCSize visibleBoundsDimensions, CCColor4B color)
     : this(new CCCamera(visibleBoundsDimensions), color)
 {
 }
Exemplo n.º 33
0
 public CCPointSprite()
 {
     Position = new CCVertex2F();
     Color = new CCColor4B();
     Size = 0.0f;
 }
Exemplo n.º 34
0
 public void DrawRect(CCRect rect, CCColor4B fillColor)
 {
     DrawRect(rect, fillColor, 0, CCColor4B.Transparent);
 }
Exemplo n.º 35
0
 public CCV3F_C4B(CCVertex3F position, CCColor4B color)
 {
     this.Vertices = position;
     Colors = color;
 }
Exemplo n.º 36
0
        public void DrawCircle(CCPoint center, float radius, float angle, int segments, CCColor4B color)
        {
            float  increment = MathHelper.Pi * 2.0f / segments;
            double theta     = 0.0;

            CCPoint        v1;
            List <CCPoint> verts = new List <CCPoint>();

            for (int i = 0; i < segments; i++)
            {
                v1 = center + new CCPoint((float)Math.Cos(theta), (float)Math.Sin(theta)) * radius;
                verts.Add(v1);
                theta += increment;
            }

            CCColor4F cf = new CCColor4F(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);

            DrawPolygon(verts.ToArray(), verts.Count, cf, 0, new CCColor4F(0f, 0f, 0f, 0f));
        }
Exemplo n.º 37
0
 public CCColor3B(CCColor4B color4B): this(color4B.R, color4B.G, color4B.B)
 {
 }
Exemplo n.º 38
0
        /// <summary>
        /// draws a cubic bezier path
        /// @since v0.8
        /// </summary>
        public static void DrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, int segments, CCColor4B color)
        {

            float t = 0;
			float increment = 1.0f / segments;

			var vertices = new CCPoint[segments];

			vertices[0] = origin;

			for (int i = 1; i < segments; ++i, t+= increment)
            {
				vertices[i].X = CCSplineMath.CubicBezier(origin.X, control1.X, control2.X, destination.X, t);
				vertices[i].Y = CCSplineMath.CubicBezier(origin.Y, control1.Y, control2.Y, destination.Y, t);
            }

			vertices[segments - 1] = destination;
			DrawPoly(vertices, color);
        }
Exemplo n.º 39
0
 /// <summary>
 /// creates a CCLayer with color, width and height in Points
 /// </summary>
 public CCLayerColor (CCCamera camera, CCColor4B color) : base(camera)
 {
     DisplayedColor = RealColor = new CCColor3B(color.R, color.G, color.B);
     DisplayedOpacity = RealOpacity = color.A;
     BlendFunc = CCBlendFunc.NonPremultiplied;
     UpdateColor();
 }
Exemplo n.º 40
0
 public void Clear(CCColor4B color, float depth, int stencil)
 {
     Clear(ClearOptions.Target | ClearOptions.Stencil | ClearOptions.DepthBuffer, color.ToColor(), depth, stencil);
 }
Exemplo n.º 41
0
 public CCLayerColor(CCSize visibleBoundsDimensions, CCColor4B color) 
     : this(new CCCamera(visibleBoundsDimensions), color)
 { }
Exemplo n.º 42
0
 public CCLayerColor(CCColor4B color) : this(null, color)
 {
 }