protected virtual CCColor4F[] ParsePropTypeColor4FVar(CCNode node, CCNode parent, CCBReader reader) { float red = reader.ReadFloat(); float green = reader.ReadFloat(); float blue = reader.ReadFloat(); float alpha = reader.ReadFloat(); float redVar = reader.ReadFloat(); float greenVar = reader.ReadFloat(); float blueVar = reader.ReadFloat(); float alphaVar = reader.ReadFloat(); var colors = new CCColor4F[2]; colors[0].R = red; colors[0].G = green; colors[0].B = blue; colors[0].A = alpha; colors[1].R = redVar; colors[1].G = greenVar; colors[1].B = blueVar; colors[1].A = alphaVar; return(colors); }
public static CCColor3B CCC3BFromCCC4F(CCColor4F floatColor) { CCColor3B color; color.R = CCColorByteFromFloat(floatColor.R); color.G = CCColorByteFromFloat(floatColor.G); color.B = CCColorByteFromFloat(floatColor.B); return color; }
public override void doTest() { CCSize s = CCDirector.SharedDirector.WinSize; CCParticleSystem particleSystem = (CCParticleSystem)GetChildByTag(PerformanceParticleTest.kTagParticleSystem); // duration particleSystem.Duration = -1; // gravity particleSystem.Gravity = new CCPoint(0, -90); // angle particleSystem.Angle = 90; particleSystem.AngleVar = 0; // radial particleSystem.RadialAccel = (0); particleSystem.RadialAccelVar = (0); // speed of particles particleSystem.Speed = (180); particleSystem.SpeedVar = (50); // emitter position particleSystem.Position = new CCPoint(s.Width / 2, 100); particleSystem.PosVar = new CCPoint(s.Width / 2, 0); // life of particles particleSystem.Life = 2.0f; particleSystem.LifeVar = 1; // emits per frame particleSystem.EmissionRate = particleSystem.TotalParticles / particleSystem.Life; // color of particles CCColor4F startColor = new CCColor4F { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f }; particleSystem.StartColor = startColor; CCColor4F startColorVar = new CCColor4F { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f }; particleSystem.StartColorVar = startColorVar; CCColor4F endColor = new CCColor4F { R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f }; particleSystem.EndColor = endColor; CCColor4F endColorVar = new CCColor4F { R = 0.1f, G = 0.1f, B = 0.1f, A = 0.2f }; particleSystem.EndColorVar = endColorVar; // size, in pixels particleSystem.EndSize = 32.0f; particleSystem.StartSize = 32.0f; particleSystem.EndSizeVar = 0; particleSystem.StartSizeVar = 0; // additive particleSystem.BlendAdditive = false; }
public static CCColor4F CCC4FBlendAlpha(CCColor4F rgba) { CCColor4F result; result.R = MathHelper.Clamp(rgba.R * rgba.A, 0.0f, 1.0f); result.G = MathHelper.Clamp(rgba.G * rgba.A, 0.0f, 1.0f); result.B = MathHelper.Clamp(rgba.B * rgba.A, 0.0f, 1.0f); result.A = rgba.A; return result; }
public static CCColor4F Lerp(CCColor4F value1, CCColor4F value2, float amount) { CCColor4F color; color.A = (value1.A + ((value2.A - value1.A) * amount)); color.R = (value1.R + ((value2.R - value1.R) * amount)); color.G = (value1.G + ((value2.G - value1.G) * amount)); color.B = (value1.B + ((value2.B - value1.B) * amount)); return(color); }
public void DrawRect(CCRect rect, CCColor4F color, float borderWidth, CCColor4F borderColor) { float x1 = rect.MinX; float y1 = rect.MinY; float x2 = rect.MaxX; float y2 = rect.MaxY; CCPoint[] pt = new CCPoint[] { new CCPoint(x1, y1), new CCPoint(x2, y1), new CCPoint(x2, y2), new CCPoint(x1, y2) }; DrawPolygon(pt, 4, color, borderWidth, borderColor); }
/// <summary> /// Creates 18 vertices that create a segment between the two points with the given radius of rounding /// on the segment end. The color is used to draw the segment. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="radius"></param> /// <param name="color"></param> /// <returns>The starting vertex index of the segment.</returns> public virtual int DrawSegment(CCPoint from, CCPoint to, float radius, CCColor4F color) { var cl = new Color(color.R, color.G, color.B, color.A); var a = from; var b = to; var n = CCPoint.Normalize(CCPoint.Perp(a - b)); var t = CCPoint.Perp(n); var nw = n * radius; var tw = t * radius; var v0 = b - (nw + tw); var v1 = b + (nw - tw); var v2 = b - nw; var v3 = b + nw; var v4 = a - nw; var v5 = a + nw; var v6 = a - (nw - tw); var v7 = a + (nw + tw); int returnIndex = m_pVertices.Count; m_pVertices.Add(new VertexPositionColor(v0, cl)); //__t(v2fneg(v2fadd(n, t))) m_pVertices.Add(new VertexPositionColor(v1, cl)); //__t(v2fsub(n, t)) m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n))} m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v1, cl)); //__t(v2fsub(n, t)) m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v6, cl)); //__t(v2fsub(t, n)) m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v6, cl)); //__t(v2fsub(t, n)) m_pVertices.Add(new VertexPositionColor(v7, cl)); //__t(v2fadd(n, t)) m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n) m_bDirty = true; return(returnIndex); }
public void DrawRect(CCRect rect, CCColor4B color) { float x1 = rect.MinX; float y1 = rect.MinY; float x2 = rect.MaxX; float y2 = rect.MaxY; CCPoint[] pt = new CCPoint[] { new CCPoint(x1, y1), new CCPoint(x2, y1), new CCPoint(x2, y2), new CCPoint(x1, y2) }; CCColor4F cf = new CCColor4F(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); DrawPolygon(pt, 4, cf, 0, new CCColor4F(0f, 0f, 0f, 0f)); }
/// <summary> /// Creates 18 vertices that create a segment between the two points with the given radius of rounding /// on the segment end. The color is used to draw the segment. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="radius"></param> /// <param name="color"></param> /// <returns>The starting vertex index of the segment.</returns> public virtual int DrawSegment(CCPoint from, CCPoint to, float radius, CCColor4F color) { var cl = new Color(color.R, color.G, color.B, color.A); var a = from; var b = to; var n = CCPoint.Normalize(CCPoint.Perp(a - b)); var t = CCPoint.Perp(n); var nw = n * radius; var tw = t * radius; var v0 = b - (nw + tw); var v1 = b + (nw - tw); var v2 = b - nw; var v3 = b + nw; var v4 = a - nw; var v5 = a + nw; var v6 = a - (nw - tw); var v7 = a + (nw + tw); int returnIndex = m_pVertices.Count; m_pVertices.Add(new VertexPositionColor(v0, cl)); //__t(v2fneg(v2fadd(n, t))) m_pVertices.Add(new VertexPositionColor(v1, cl)); //__t(v2fsub(n, t)) m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n))} m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v1, cl)); //__t(v2fsub(n, t)) m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v2, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v3, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v6, cl)); //__t(v2fsub(t, n)) m_pVertices.Add(new VertexPositionColor(v4, cl)); //__t(v2fneg(n)) m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n) m_pVertices.Add(new VertexPositionColor(v6, cl)); //__t(v2fsub(t, n)) m_pVertices.Add(new VertexPositionColor(v7, cl)); //__t(v2fadd(n, t)) m_pVertices.Add(new VertexPositionColor(v5, cl)); //__t(n) m_bDirty = true; return (returnIndex); }
public LCC3Material(int tag, string name) : base(tag, name) { _textureOverlays = new List<LCC3Texture>(); _ambientColor = LCC3Material.CC3DefaultMaterialColorAmbient; _diffuseColor = LCC3Material.CC3DefaultMaterialColorDiffuse; _specularColor = LCC3Material.CC3DefaultMaterialColorSpecular; _emissionColor = LCC3Material.CC3DefaultMaterialColorEmission; _shininess = LCC3Material.CC3DefaultMaterialShininess; _reflectivity = LCC3Material.CC3DefaultMaterialReflectivity; _srcBlendType = LCC3BlendType.One; _dstBlendType = LCC3BlendType.Zero; _alphaTestFunc = LCC3AlphaTestFuncMode.Always; _shouldUseLighting = true; }
public void DrawCircleOutline(CCPoint center, float radius, float lineWidth, float angle, int segments, CCColor4B color) { float increment = MathHelper.Pi * 2.0f / segments; double theta = 0.0; CCPoint v1; CCPoint v2 = CCPoint.Zero; CCColor4F cf = new CCColor4F(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f); for (int i = 0; i < segments; i++) { v1 = center + new CCPoint((float)Math.Cos(theta), (float)Math.Sin(theta)) * radius; v2 = center + new CCPoint((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment)) * radius; DrawSegment(v1, v2, lineWidth, cf); theta += increment; } }
/** draw a dot at a position, with a given radius and color */ public void DrawDot(CCPoint pos, float radius, CCColor4F color) { var cl = new Color(color.R, color.G, color.B, color.A); var a = new VertexPositionColor(new Vector3(pos.X - radius, pos.Y - radius, 0), cl); //{-1.0, -1.0} var b = new VertexPositionColor(new Vector3(pos.X - radius, pos.Y + radius, 0), cl); //{-1.0, 1.0} var c = new VertexPositionColor(new Vector3(pos.X + radius, pos.Y + radius, 0), cl); //{ 1.0, 1.0} var d = new VertexPositionColor(new Vector3(pos.X + radius, pos.Y - radius, 0), cl); //{ 1.0, -1.0} m_pVertices.Add(a); m_pVertices.Add(b); m_pVertices.Add(c); m_pVertices.Add(a); m_pVertices.Add(c); m_pVertices.Add(d); m_bDirty = true; }
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; CCPoint v2 = CCPoint.Zero; 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; v2 = center + new CCPoint((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment)) * 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)); }
public override void OnEnter() { base.OnEnter(); Color = CCTypes.CCBlack; RemoveChild(m_background, true); m_background = null; m_pBatchNode = new CCParticleBatchNode("Images/stars-grayscale", 3000); AddChild(m_pBatchNode, 1, 2); for (int i = 0; i < 3; i++) { var particleSystem = new CCParticleSystemQuad(); particleSystem.InitWithTotalParticles(200); particleSystem.Texture = (m_pBatchNode.Texture); // duration particleSystem.Duration = CCParticleSystem.kCCParticleDurationInfinity; // radius mode particleSystem.EmitterMode = CCEmitterMode.Radius; // radius mode: 100 pixels from center particleSystem.StartRadius = (100); particleSystem.StartRadiusVar = (0); particleSystem.EndRadius = (CCParticleSystem.kCCParticleStartRadiusEqualToEndRadius); particleSystem.EndRadiusVar = (0); // not used when start == end // radius mode: degrees per second // 45 * 4 seconds of life = 180 degrees particleSystem.RotatePerSecond = (45); particleSystem.RotatePerSecondVar = (0); // angle particleSystem.Angle = (90); particleSystem.AngleVar = (0); // emitter position particleSystem.PosVar = (CCPoint.Zero); // life of particles particleSystem.Life = (4); particleSystem.LifeVar = (0); // spin of particles particleSystem.StartSpin = (0); particleSystem.StartSpinVar = (0); particleSystem.EndSpin = (0); particleSystem.EndSpinVar = (0); // color of particles var color = new float[3] {0, 0, 0}; color[i] = 1; var startColor = new CCColor4F(color[0], color[1], color[2], 1.0f); particleSystem.StartColor = (startColor); var startColorVar = new CCColor4F(0, 0, 0, 0); particleSystem.StartColorVar = (startColorVar); CCColor4F endColor = startColor; particleSystem.EndColor = (endColor); CCColor4F endColorVar = startColorVar; particleSystem.EndColorVar = (endColorVar); // size, in pixels particleSystem.StartSize = (32); particleSystem.StartSizeVar = (0); particleSystem.EndSize = CCParticleSystem.kCCParticleStartSizeEqualToEndSize; // emits per second particleSystem.EmissionRate = (particleSystem.TotalParticles / particleSystem.Life); // additive particleSystem.Position = (new CCPoint(i * 10 + 120, 200)); m_pBatchNode.AddChild(particleSystem); particleSystem.PositionType = CCPositionType.Free; //[pBNode addChild:particleSystem z:10 tag:0); } Schedule(reorderSystem, 2.0f); m_emitter = null; }
public override void OnEnter() { base.OnEnter(); m_emitter = new CCParticleSystemQuad(); m_emitter.InitWithTotalParticles(300); //m_emitter.autorelease(); m_background.AddChild(m_emitter, 10); ////m_emitter.release(); // win32 : Remove this line m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_stars2); // duration m_emitter.Duration = -1; // gravity m_emitter.Gravity = (new CCPoint(0, 0)); // angle m_emitter.Angle = 90; m_emitter.AngleVar = 360; // speed of particles m_emitter.Speed = (160); m_emitter.SpeedVar = (20); // radial m_emitter.RadialAccel = (-120); m_emitter.RadialAccelVar = (0); // tagential m_emitter.TangentialAccel = (30); m_emitter.TangentialAccelVar = (0); // emitter position m_emitter.Position = new CCPoint(160, 240); m_emitter.PosVar = new CCPoint(0, 0); // life of particles m_emitter.Life = 3; m_emitter.LifeVar = 1; // spin of particles m_emitter.StartSpin = 0; m_emitter.StartSpinVar = 0; m_emitter.EndSpin = 0; m_emitter.EndSpinVar = 2000; // color of particles var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColor = startColor; var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColorVar = startColorVar; var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColor = endColor; var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColorVar = endColorVar; // size, in pixels m_emitter.StartSize = 30.0f; m_emitter.StartSizeVar = 00.0f; m_emitter.EndSize = CCParticleSystem.kParticleStartSizeEqualToEndSize; // emits per second m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life; // additive m_emitter.BlendAdditive = false; setEmitterPosition(); }
public void SetColor4FAtIndex(CCColor4F color, uint index) { switch (_elementType) { case LCC3ElementType.Fixed: case LCC3ElementType.UnsignedByte: _vertices[(int)index] = LCC3ColorUtil.CCC4BFromCCC4F(color); break; default: _vertices[(int)index] = color; break; } }
public override void OnEnter() { base.OnEnter(); Color = new CCColor3B(0, 0, 0); RemoveChild(m_background, true); m_background = null; m_emitter = new CCParticleSystemQuad(); m_emitter.InitWithTotalParticles(100); AddChild(m_emitter, 10); m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); // duration m_emitter.Duration = CCParticleSystem.kCCParticleDurationInfinity; // radius mode m_emitter.EmitterMode = CCEmitterMode.Radius; // radius mode: start and end radius in pixels m_emitter.StartRadius = (50); m_emitter.StartRadiusVar = (0); m_emitter.EndRadius = (CCParticleSystem.kCCParticleStartRadiusEqualToEndRadius); m_emitter.EndRadiusVar = (0); // radius mode: degrees per second m_emitter.RotatePerSecond = (0); m_emitter.RotatePerSecondVar = (0); // angle m_emitter.Angle = 90; m_emitter.AngleVar = 0; // emitter position CCSize size = CCDirector.SharedDirector.WinSize; m_emitter.Position = new CCPoint(size.Width / 2, size.Height / 2); m_emitter.PosVar = new CCPoint(0, 0); // life of particles m_emitter.Life = 5; m_emitter.LifeVar = 0; // spin of particles m_emitter.StartSpin = 0; m_emitter.StartSpinVar = 0; m_emitter.EndSpin = 0; m_emitter.EndSpinVar = 0; // color of particles var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColor = startColor; var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColorVar = startColorVar; var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColor = endColor; var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColorVar = endColorVar; // size, in pixels m_emitter.StartSize = 16; m_emitter.StartSizeVar = 0; m_emitter.EndSize = CCParticleSystem.kCCParticleStartSizeEqualToEndSize; // emits per second m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life; // additive m_emitter.BlendAdditive = false; CCRotateBy rot = new CCRotateBy (16, 360); m_emitter.RunAction(new CCRepeatForever (rot)); }
public LCC3Light() { _ambientColor = LCC3ColorUtil.CCC4FBlackTransparent; _diffuseColor = LCC3ColorUtil.CCC4FBlackTransparent; _specularColor = LCC3ColorUtil.CCC4FBlackTransparent; }
public void PopulateFrom(LCC3Material anotherMaterial) { base.PopulateFrom(anotherMaterial); _ambientColor = anotherMaterial.AmbientColor; _diffuseColor = anotherMaterial.DiffuseColor; _specularColor = anotherMaterial.SpecularColor; _emissionColor = anotherMaterial.EmissionColor; _shininess = anotherMaterial.Shininess; _reflectivity = anotherMaterial.Reflectivity; _srcBlendType = anotherMaterial._srcBlendType; _dstBlendType = anotherMaterial._dstBlendType; _alphaTestFunc = anotherMaterial._alphaTestFunc; _shouldUseLighting = anotherMaterial._shouldUseLighting; _shaderContext = anotherMaterial.ShaderContext; _texture = anotherMaterial.Texture; _textureOverlays.Clear(); _textureOverlays.AddRange(anotherMaterial.TextureOverlays); }
public void DrawRect(CCRect rect, CCColor4F color, float borderWidth, CCColor4F borderColor) { float x1 = rect.MinX; float y1 = rect.MinY; float x2 = rect.MaxX; float y2 = rect.MaxY; CCPoint[] pt = new CCPoint[] { new CCPoint(x1,y1), new CCPoint(x2,y1), new CCPoint(x2,y2), new CCPoint(x1,y2) }; DrawPolygon(pt, 4, color, borderWidth, borderColor); }
public void DrawRect(CCRect rect, CCColor4B color) { float x1 = rect.MinX; float y1 = rect.MinY; float x2 = rect.MaxX; float y2 = rect.MaxY; CCPoint[] pt = new CCPoint[] { new CCPoint(x1,y1), new CCPoint(x2,y1), new CCPoint(x2,y2), new CCPoint(x1,y2) }; CCColor4F cf = new CCColor4F(color.R/255f, color.G/255f, color.B/255f, color.A/255f); DrawPolygon(pt, 4, cf, 0, new CCColor4F(0f, 0f, 0f, 0f)); }
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; CCPoint v2 = CCPoint.Zero; 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; v2 = center + new CCPoint((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment)) * 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)); }
public override void Setup() { var s = CCDirector.SharedDirector.WinSize; CCClippingNode clipper = new CCClippingNode(); clipper.Tag = kTagClipperNode; clipper.ContentSize = new CCSize(200, 200); clipper.AnchorPoint = new CCPoint(0.5f, 0.5f); clipper.Position = ContentSize.Center; clipper.RunAction(new CCRepeatForever(new CCRotateBy(1, 45))); AddChild(clipper); CCDrawNode stencil = new CCDrawNode(); CCPoint[] rectangle = { new CCPoint(0, 0), new CCPoint(clipper.ContentSize.Width, 0), new CCPoint(clipper.ContentSize.Width, clipper.ContentSize.Height), new CCPoint(0, clipper.ContentSize.Height), }; CCColor4F white = new CCColor4F(1, 1, 1, 1); stencil.DrawPolygon(rectangle, 4, white, 0, white); clipper.Stencil = stencil; CCSprite content = new CCSprite(TestResource.s_back2); content.Tag = kTagContentNode; content.AnchorPoint = new CCPoint(0.5f, 0.5f); content.Position = clipper.ContentSize.Center; clipper.AddChild(content); m_bScrolling = false; TouchEnabled = true; }
public static CCColor4F operator *(CCColor4F c, float amt) { CCColor4F nc = new CCColor4F(c.R * amt, c.G * amt, c.B * amt, c.A); return (nc); }
/** returns YES if both ccColor4F are equal. Otherwise it returns NO. @since v0.99.1 */ public static bool ColorsAreEqual(CCColor4F a, CCColor4F b) { return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A; }
public LCC3Texture(int tag, string name) : base(tag, name) { _texUnitConstantColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f); }
public override void OnEnter() { base.OnEnter(); m_emitter = new CCParticleSystemQuad(); m_emitter.InitWithTotalParticles(1000); //m_emitter.autorelease(); m_background.AddChild(m_emitter, 10); ////m_emitter.release(); CCSize s = CCDirector.SharedDirector.WinSize; // duration m_emitter.Duration = -1; // gravity m_emitter.Gravity = (new CCPoint(0, 0)); // angle m_emitter.Angle = 0; m_emitter.AngleVar = 360; // radial m_emitter.RadialAccel = (70); m_emitter.RadialAccelVar = (10); // tagential m_emitter.TangentialAccel = (80); m_emitter.TangentialAccelVar = (0); // speed of particles m_emitter.Speed = (50); m_emitter.SpeedVar = (10); // emitter position m_emitter.Position = new CCPoint(s.Width / 2, s.Height / 2); m_emitter.PosVar = new CCPoint(0, 0); // life of particles m_emitter.Life = 2.0f; m_emitter.LifeVar = 0.3f; // emits per frame m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life; // color of particles var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColor = startColor; var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColorVar = startColorVar; var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColor = endColor; var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColorVar = endColorVar; // size, in pixels m_emitter.StartSize = 1.0f; m_emitter.StartSizeVar = 1.0f; m_emitter.EndSize = 32.0f; m_emitter.EndSizeVar = 8.0f; // texture m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire); // additive m_emitter.BlendAdditive = false; setEmitterPosition(); }
public static CCColor4F Lerp(CCColor4F value1, CCColor4F value2, float amount) { CCColor4F color; color.A = (value1.A + ((value2.A - value1.A) * amount)); color.R = (value1.R + ((value2.R - value1.R) * amount)); color.G = (value1.G + ((value2.G - value1.G) * amount)); color.B = (value1.B + ((value2.B - value1.B) * amount)); return color; }
public void DrawPolygon(CCPoint[] verts, int count, CCColor4F fillColor, float borderWidth, CCColor4F borderColor) { var extrude = new ExtrudeVerts[count]; for (int i = 0; i < count; i++) { var v0 = verts[(i - 1 + count) % count]; var v1 = verts[i]; var v2 = verts[(i + 1) % count]; var n1 = CCPoint.Normalize(CCPoint.Perp(v1 - v0)); var n2 = CCPoint.Normalize(CCPoint.Perp(v2 - v1)); var offset = (n1 + n2) * (1.0f / (CCPoint.Dot(n1, n2) + 1.0f)); extrude[i] = new ExtrudeVerts() {offset = offset, n = n2}; } bool outline = (fillColor.A > 0.0f && borderWidth > 0.0f); float inset = (!outline ? 0.5f : 0.0f); for (int i = 0; i < count - 2; i++) { var v0 = verts[0] - (extrude[0].offset * inset); var v1 = verts[i + 1] - (extrude[i + 1].offset * inset); var v2 = verts[i + 2] - (extrude[i + 2].offset * inset); m_pVertices.Add(new VertexPositionColor(v0, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(v1, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(v2, fillColor)); //__t(v2fzero) } for (int i = 0; i < count; i++) { int j = (i + 1) % count; var v0 = verts[i]; var v1 = verts[j]; var n0 = extrude[i].n; var offset0 = extrude[i].offset; var offset1 = extrude[j].offset; if (outline) { var inner0 = (v0 - (offset0 * borderWidth)); var inner1 = (v1 - (offset1 * borderWidth)); var outer0 = (v0 + (offset0 * borderWidth)); var outer1 = (v1 + (offset1 * borderWidth)); m_pVertices.Add(new VertexPositionColor(inner0, borderColor)); //__t(v2fneg(n0)) m_pVertices.Add(new VertexPositionColor(inner1, borderColor)); //__t(v2fneg(n0)) m_pVertices.Add(new VertexPositionColor(outer1, borderColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(inner0, borderColor)); //__t(v2fneg(n0)) m_pVertices.Add(new VertexPositionColor(outer0, borderColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(outer1, borderColor)); //__t(n0) } else { var inner0 = (v0 - (offset0 * 0.5f)); var inner1 = (v1 - (offset1 * 0.5f)); var outer0 = (v0 + (offset0 * 0.5f)); var outer1 = (v1 + (offset1 * 0.5f)); m_pVertices.Add(new VertexPositionColor(inner0, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(inner1, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(outer1, fillColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(inner0, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(outer0, fillColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(outer1, fillColor)); //__t(n0) } } m_bDirty = true; }
public void DrawPolygon(CCPoint[] verts, int count, CCColor4F fillColor, float borderWidth, CCColor4F borderColor) { var extrude = new ExtrudeVerts[count]; for (int i = 0; i < count; i++) { var v0 = verts[(i - 1 + count) % count]; var v1 = verts[i]; var v2 = verts[(i + 1) % count]; var n1 = CCPoint.Normalize(CCPoint.Perp(v1 - v0)); var n2 = CCPoint.Normalize(CCPoint.Perp(v2 - v1)); var offset = (n1 + n2) * (1.0f / (CCPoint.Dot(n1, n2) + 1.0f)); extrude[i] = new ExtrudeVerts() { offset = offset, n = n2 }; } bool outline = (fillColor.A > 0.0f && borderWidth > 0.0f); float inset = (!outline ? 0.5f : 0.0f); for (int i = 0; i < count - 2; i++) { var v0 = verts[0] - (extrude[0].offset * inset); var v1 = verts[i + 1] - (extrude[i + 1].offset * inset); var v2 = verts[i + 2] - (extrude[i + 2].offset * inset); m_pVertices.Add(new VertexPositionColor(v0, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(v1, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(v2, fillColor)); //__t(v2fzero) } for (int i = 0; i < count; i++) { int j = (i + 1) % count; var v0 = verts[i]; var v1 = verts[j]; var n0 = extrude[i].n; var offset0 = extrude[i].offset; var offset1 = extrude[j].offset; if (outline) { var inner0 = (v0 - (offset0 * borderWidth)); var inner1 = (v1 - (offset1 * borderWidth)); var outer0 = (v0 + (offset0 * borderWidth)); var outer1 = (v1 + (offset1 * borderWidth)); m_pVertices.Add(new VertexPositionColor(inner0, borderColor)); //__t(v2fneg(n0)) m_pVertices.Add(new VertexPositionColor(inner1, borderColor)); //__t(v2fneg(n0)) m_pVertices.Add(new VertexPositionColor(outer1, borderColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(inner0, borderColor)); //__t(v2fneg(n0)) m_pVertices.Add(new VertexPositionColor(outer0, borderColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(outer1, borderColor)); //__t(n0) } else { var inner0 = (v0 - (offset0 * 0.5f)); var inner1 = (v1 - (offset1 * 0.5f)); var outer0 = (v0 + (offset0 * 0.5f)); var outer1 = (v1 + (offset1 * 0.5f)); m_pVertices.Add(new VertexPositionColor(inner0, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(inner1, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(outer1, fillColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(inner0, fillColor)); //__t(v2fzero) m_pVertices.Add(new VertexPositionColor(outer0, fillColor)); //__t(n0) m_pVertices.Add(new VertexPositionColor(outer1, fillColor)); //__t(n0) } } m_bDirty = true; }
/** Returns a ccColor4F from a ccColor4B. @since v0.99.1 */ public static CCColor4F CreateColor(CCColor4B c) { CCColor4F c4 = new CCColor4F(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f); return c4; }
public static CCColor4F operator +(CCColor4F c, float amt) { CCColor4F nc = new CCColor4F(c.R + amt, c.G + amt, c.B + amt, c.A); return(nc); }
/** Returns a ccColor4F from a ccColor4B. * @since v0.99.1 */ public static CCColor4F CreateColor(CCColor4B c) { CCColor4F c4 = new CCColor4F(c.R / 255.0f, c.G / 255.0f, c.B / 255.0f, c.A / 255.0f); return(c4); }
public static CCColor4F operator +(CCColor4F c, float amt) { CCColor4F nc = new CCColor4F(c.R + amt, c.G + amt, c.B + amt, c.A); return (nc); }
public static CCColor4F operator *(CCColor4F c, float amt) { CCColor4F nc = new CCColor4F(c.R * amt, c.G * amt, c.B * amt, c.A); return(nc); }
public static CCColor4F operator /(CCColor4F c, float amt) { CCColor4F nc = new CCColor4F(c.R / amt, c.G / amt, c.B / amt, c.A); return (nc); }
public static CCColor4F operator /(CCColor4F c, float amt) { CCColor4F nc = new CCColor4F(c.R / amt, c.G / amt, c.B / amt, c.A); return(nc); }
public CCV2F_C4F_T2F() { Vertices = new CCVertex2F(); Colors = new CCColor4F(); TexCoords = new CCTex2F(); }
protected virtual void OnHandlePropTypeColor4FVar(CCNode node, CCNode parent, string propertyName, CCColor4F[] colorVar, CCBReader reader) { CCLog.Log("Unexpected property type: '{0}'!", propertyName); Debug.Assert(false); }
protected virtual CCColor4F[] ParsePropTypeColor4FVar(CCNode node, CCNode parent, CCBReader reader) { float red = reader.ReadFloat(); float green = reader.ReadFloat(); float blue = reader.ReadFloat(); float alpha = reader.ReadFloat(); float redVar = reader.ReadFloat(); float greenVar = reader.ReadFloat(); float blueVar = reader.ReadFloat(); float alphaVar = reader.ReadFloat(); var colors = new CCColor4F[2]; colors[0].R = red; colors[0].G = green; colors[0].B = blue; colors[0].A = alpha; colors[1].R = redVar; colors[1].G = greenVar; colors[1].B = blueVar; colors[1].A = alphaVar; return colors; }
/** returns YES if both ccColor4F are equal. Otherwise it returns NO. * @since v0.99.1 */ public static bool ColorsAreEqual(CCColor4F a, CCColor4F b) { return(a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A); }
public void SetVertexColor4FAtIndex(CCColor4F color, uint index) { _vertexColors.SetColor4FAtIndex(color, index); }