private TriangleParticle createTriangle(bool randomY) { TriangleParticle particle = CreateTriangle(); particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1); particle.Colour = CreateTriangleShade(); return(particle); }
private TriangleParticle createTriangle(bool randomY) { TriangleParticle particle = CreateTriangle(); particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1); particle.Colour = MultipleColours ? Colours[RNG.Next(0, Colours.Length - 1)] : CreateTriangleShade(); return(particle); }
protected override void Update() { base.Update(); Velocity = 2.32222f + (float)Math.Pow((meta.Value?.Track?.CurrentAmplitudes.Average ?? 0) * 2 + .5, 2.5); Invalidate(Invalidation.DrawNode, shallPropagate: false); if (CreateNewTriangles) { addTriangles(false); } float adjustedAlpha = HideAlphaDiscrepancies ? // Cubically scale alpha to make it drop off more sharply. (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : 1; float elapsedSeconds = (float)Time.Elapsed / 1000; // Since position is relative, the velocity needs to scale inversely with DrawHeight. // Since we will later multiply by the scale of individual triangles we normalize by // dividing by triangleScale. float movedDistance = -elapsedSeconds * Velocity * base_velocity / (DrawHeight * triangleScale); for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; // Scale moved distance by the size of the triangle. Smaller triangles should move more slowly. newParticle.Position.Y += parts[i].Scale * movedDistance; parts[i] = newParticle; float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight; if (bottomPos < 0) { parts.RemoveAt(i); } } }
protected override void Update() { base.Update(); Invalidate(Invalidation.DrawNode, shallPropagate: false); for (int i = 0; i < parts.Count; i++) { TriangleParticle newParticle = parts[i]; float adjustedAlpha = HideAlphaDiscrepancies ? // Cubically scale alpha to make it drop off more sharply. (float)Math.Pow(DrawInfo.Colour.AverageColour.Linear.A, 3) : 1; newParticle.Position += new Vector2(0, -(parts[i].Scale * (50 / DrawHeight)) / triangleScale * Velocity) * ((float)Time.Elapsed / 950); newParticle.Colour.A = adjustedAlpha; parts[i] = newParticle; if (!CreateNewTriangles) { continue; } float bottomPos = parts[i].Position.Y + triangle_size * parts[i].Scale * 0.866f / DrawHeight; if (bottomPos < 0) { parts.RemoveAt(i); } } addTriangles(false); }