예제 #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();
        }
예제 #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;

        }
예제 #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;
		}
예제 #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;
 }
예제 #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);
        }
예제 #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;
			//}
		}
예제 #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);
        }
예제 #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);
        }
        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;

        }
예제 #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;
        }
예제 #16
0
 public void Clear(CCColor4B color, float depth)
 {
     Clear(color, depth, 0);
 }
예제 #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;
        }
예제 #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;
 }
예제 #19
0
 public CCV2F_C4B_T2F()
 {
     Vertices = new CCVertex2F();
     Colors = new CCColor4B();
     TexCoords = new CCTex2F();
 }
예제 #20
0
 public CCColor4F(CCColor4B color4B) : this(color4B.R / 255.0f, color4B.G / 255.0f, color4B.B / 255.0f, color4B.A / 255.0f)
 {
 }
예제 #21
0
 public bool Equals(CCColor4B other)        
 {            
     return this == other;       
 } 
예제 #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();
            }
        }
예제 #24
0
 public void BeginWithClear(CCColor4B clearColor, float depth = 1.0f, int stencil = 0)
 {
     ClearColor = clearColor;
     Begin();
 }
예제 #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;
            }
        }
예제 #26
0
 public void Clear(CCColor4B color)
 {
     Clear(color, 1.0f);
 }
예제 #27
0
 public static void DrawPoints(CCPoint[] points, float size, CCColor4B color)
 {
     DrawPoints(points, points.Length, size, color);
 }
예제 #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();
		}
예제 #30
0
 public CCLayerColor(CCColor4B color) : this(CCSize.Zero, color)
 {
 }
예제 #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;
        }
예제 #32
0
 public CCLayerColor(CCSize visibleBoundsDimensions, CCColor4B color)
     : this(new CCCamera(visibleBoundsDimensions), color)
 {
 }
예제 #33
0
 public CCPointSprite()
 {
     Position = new CCVertex2F();
     Color = new CCColor4B();
     Size = 0.0f;
 }
예제 #34
0
 public void DrawRect(CCRect rect, CCColor4B fillColor)
 {
     DrawRect(rect, fillColor, 0, CCColor4B.Transparent);
 }
예제 #35
0
 public CCV3F_C4B(CCVertex3F position, CCColor4B color)
 {
     this.Vertices = position;
     Colors = color;
 }
예제 #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));
        }
예제 #37
0
 public CCColor3B(CCColor4B color4B): this(color4B.R, color4B.G, color4B.B)
 {
 }
예제 #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);
        }
예제 #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();
 }
예제 #40
0
 public void Clear(CCColor4B color, float depth, int stencil)
 {
     Clear(ClearOptions.Target | ClearOptions.Stencil | ClearOptions.DepthBuffer, color.ToColor(), depth, stencil);
 }
예제 #41
0
 public CCLayerColor(CCSize visibleBoundsDimensions, CCColor4B color) 
     : this(new CCCamera(visibleBoundsDimensions), color)
 { }
예제 #42
0
 public CCLayerColor(CCColor4B color) : this(null, color)
 {
 }