public void RenderColorWash(bool HorizFade, bool VertFade, int RepeatCount) { const int SpeedFactor = 200; int x, y; Color color; HSV hsv2 = new HSV(); int colorcnt = GetColorCount(); int CycleLen = colorcnt*SpeedFactor; if (State > (colorcnt - 1)*SpeedFactor*RepeatCount && RepeatCount < 10) { //Console.WriteLine("1"); color = GetMultiColorBlend((double) (RepeatCount%2), false); } else { //Console.WriteLine("2"); color = GetMultiColorBlend((double) (State%CycleLen)/(double) CycleLen, true); } HSV hsv = HSV.ColorToHSV(color); double HalfHt = (double) (BufferHt - 1)/2.0; double HalfWi = (double) (BufferWi - 1)/2.0; for (x = 0; x < BufferWi; x++) { for (y = 0; y < BufferHt; y++) { hsv2.SetToHSV(hsv); if (HorizFade && HalfWi > 0) hsv2.Value *= (float) (1.0 - Math.Abs(HalfWi - x)/HalfWi); if (VertFade && HalfHt > 0) hsv2.Value *= (float) (1.0 - Math.Abs(HalfHt - y)/HalfHt); //SetPixel(x, y, hsv); SetPixel(x, y, hsv2); //SetPixel(x, y, color); } } }
private void RenderMeteors(int MeteorType, int Count, int Length) { if (State == 0) meteors.Clear(); int mspeed = (int) State/4; State -= mspeed*4 - 1; // create new meteors HSV hsv = new HSV(); HSV hsv0 = new HSV(); HSV hsv1 = new HSV(); hsv0 = Palette.GetHSV(0); hsv1 = Palette.GetHSV(1); int colorcnt = GetColorCount(); Count = BufferWi*Count/100; int TailLength = (BufferHt < 10) ? Length/10 : BufferHt*Length/100; if (TailLength < 1) TailLength = 1; int TailStart = BufferHt - TailLength; if (TailStart < 1) TailStart = 1; for (int i = 0; i < Count; i++) { MeteorClass m = new MeteorClass(); m.x = rand()%BufferWi; m.y = BufferHt - 1 - (rand()%TailStart); switch (MeteorType) { case 1: m.hsv = HSV.SetRangeColor(hsv0, hsv1); break; case 2: m.hsv = Palette.GetHSV(rand()%colorcnt); break; } meteors.Add(m); } // render meteors foreach (MeteorClass meteor in meteors) { { for (int ph = 0; ph < TailLength; ph++) { switch (MeteorType) { case 0: hsv.Hue = (float) (rand()%1000)/1000.0f; hsv.Saturation = 1.0f; hsv.Value = 1.0f; break; default: hsv.SetToHSV(meteor.hsv); break; } hsv.Value *= (float) (1.0 - (double) ph/TailLength); SetPixel(meteor.x, meteor.y + ph, hsv); } meteor.y -= mspeed; } } // delete old meteors int meteorNum = 0; while (meteorNum < meteors.Count) { if (meteors[meteorNum].HasExpired(TailLength)) { meteors.RemoveAt(meteorNum); } else { meteorNum++; } } }