private static void InitPalette() { HSV hsv = new HSV(); Color color; Palette.Clear(); int i; // calc 100 reds, black to bright red hsv.H = 0.0f; hsv.S = 1.0f; for (i = 0; i < 100; i++) { hsv.V = i / 100.0f; color = hsv.ToRGB().ToArgb(); Palette.Add(color); } // gives 100 hues red to yellow hsv.V = 1.0f; for (i = 0; i < 100; i++) { color = hsv.ToRGB().ToArgb(); Palette.Add(color); hsv.H += 0.00166666f; } }
public void Reset(int x, int y, bool active, float velocity, HSV hsv) { X = x; Y = y; Vel = (Random.Next() - int.MaxValue / 2) * velocity / (int.MaxValue / 2); Angle = (float)(2 * Math.PI * Random.Next() / int.MaxValue); Dx = (float)(Vel * Math.Cos(Angle)); Dy = (float)(Vel * Math.Sin(Angle)); Active = active; Cycles = 0; HSV = hsv; }
public void Reset(int x, int y, bool active, float velocity, HSV hsv, int start, int colorLocation) { X = x; Y = y; Vel = (Random.Next() - int.MaxValue / 2) * velocity / (int.MaxValue / 2); Angle = (float)(2 * Math.PI * Random.Next() / int.MaxValue); Dx = (float)(Vel * Math.Cos(Angle)); Dy = (float)(Vel * Math.Sin(Angle)); Active = active; Cycles = 0; HSV = hsv; ColorLocation = colorLocation; StartPeriod = start; }
public static HSV FromRGB(double r, double g, double b) { double min = Math.Min(Math.Min(r, g), b), max = Math.Max(Math.Max(r, g), b), delta_max = max - min; HSV ret = new HSV { _v = max }; if (delta_max > 0.0) { ret._s = delta_max / max; double del_R = (((max - r) / 6.0) + (delta_max / 2.0)) / delta_max; double del_G = (((max - g) / 6.0) + (delta_max / 2.0)) / delta_max; double del_B = (((max - b) / 6.0) + (delta_max / 2.0)) / delta_max; if (r == max) { ret._h = del_B - del_G; } else if (g == max) { ret._h = (1.0 / 3.0) + del_R - del_B; } else if (b == max) { ret._h = (2.0 / 3.0) + del_G - del_R; } if (ret._h < 0.0) { ret._h += 1.0; } if (ret._h > 1.0) { ret._h -= 1.0; } } return(ret); }
protected override void SetupRender() { InitFireworksBuffer(); ResetBurstBuffer(); var x25 = (int)(BufferWi * 0.25); var x75 = (int)(BufferWi * 0.75); var y25 = (int)(BufferHt * 0.25); var y75 = (int)(BufferHt * 0.75); ResetBurstBuffer(); // Create new bursts for (int x = 0; x < Explosions; x++) { HSV hsv = new HSV(); if (ColorType == FireworksColorType.Random) { hsv.H = (float)(Rand() % 1000) / 1000.0f; hsv.S = 1.0f; hsv.V = 1.0f; } int start = (int)(Rand01() * GetNumberFrames()); int startX; int startY; if ((x75 - x25) > 0) startX = x25 + Rand() % (x75 - x25); else startX = 0; if ((y75 - y25) > 0) startY = y25 + Rand() % (y75 - y25); else startY = 0; int colorLocation = Rand() % ColorGradients.Count; int randomParticles = RandomParticles ? _random.Next(MinParticles, MaxParticles) : Particles; for (int i = 0; i < randomParticles; i++) { int velocity = RandomVelocity ? _random.Next(MinVelocity, MaxVelocity) : Velocity; _fireworkBursts[x * Particles + i].Reset(startX, startY, false, velocity, hsv, start, colorLocation); } } }
//Use for Range type public static HSV SetRangeColor(HSV hsv1, HSV hsv2) { HSV newHsv = new HSV(RandomRange((float)hsv1.H, (float)hsv2.H), RandomRange((float)hsv1.S, (float)hsv2.S), 1.0f); return newHsv; }
protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer) { if (frame == 0) _meteors.Clear(); int colorcnt = Colors.Count(); int tailLength = (BufferHt < 10) ? Length/10 : BufferHt*Length/100; int minDirection = 1; int maxDirection = 360; if (tailLength < 1) tailLength = 1; int tailStart = BufferHt; if (tailStart < 1) tailStart = 1; // create new meteors and maintain maximum number as per users selection. HSV hsv = new HSV(); int pixelCount = frame < PixelCount ? (!RandomMeteorPosition && frame > PixelCount ? 1 : (PixelCount < 10 ? PixelCount : PixelCount / 10)) : PixelCount; for (int i = 0; i < pixelCount; i++) { double position = RandomSpeed ? (double)_random.Next(MinSpeed, MaxSpeed + 1) / 20 : (double)Speed / 20; if (_meteors.Count >= PixelCount) continue; MeteorClass m = new MeteorClass(); if (MeteorEffect == MeteorsEffect.RandomDirection) { minDirection = MinDirection; maxDirection = MaxDirection; } int direction; if (MeteorEffect == MeteorsEffect.None) direction = Direction; //Set Range for standard Meteor as we don't want to just have them going straight down or two dirctions like the original Meteor effect. else { //This is to generate random directions between the Min and Max values //However if Someone makes the MaxDirection lower then the Min Direction then //the new direction will be the inverserve of the Min and Max effectively changing //the range from a downward motion to an upward motion, increasing the feature capability. if (maxDirection <= minDirection) { //used for the Upward movement of the Meteor (added feature) direction = _random.Next(1, 3) == 1 ? _random.Next(1, maxDirection) : _random.Next(minDirection, 360); } else { //used for the downward movemnet of the Meteor (standard way) direction = _random.Next(minDirection, maxDirection); } } //Moving m.X = rand() % BufferWi; m.Y = rand() % BufferHt; if (direction >= 0 && direction <= 90) { m.TailX = ((double)direction / 90); m.DeltaX = m.TailX * position; m.TailY = ((double)Math.Abs(direction - 90) / 90); m.DeltaY = m.TailY * position; if (_random.NextDouble() >= (double)(90 - direction) / 100) { m.X = 0; m.Y = rand() % BufferHt; } else { m.X = rand()%BufferWi; m.Y = 0; } } else if (direction > 90 && direction <= 180) { m.TailX = ((double)Math.Abs(direction - 180) / 90); m.DeltaX = m.TailX * position; m.TailY = -1 * ((double)Math.Abs(direction - 90) / 90); m.DeltaY = m.TailY * position; if (_random.NextDouble() >= (double)(180 - direction) / 100) { m.X = rand() % BufferWi; m.Y = BufferHt; } else { m.X = 0; m.Y = rand() % BufferHt; } } else if (direction > 180 && direction <= 270) { m.TailX = -1 * ((double)Math.Abs(direction - 180) / 90); m.DeltaX = m.TailX * position; m.TailY = -1 * ((double)Math.Abs(direction - 270) / 90); m.DeltaY = m.TailY * position; if (_random.NextDouble() >= (double)(270 - direction) / 100) { m.X = BufferWi; m.Y = rand() % BufferHt; } else { m.X = rand() % BufferWi; m.Y = BufferHt; } } else if (direction > 270 && direction <= 360) { m.TailX = -1 * ((double)Math.Abs(direction - 360) / 90); m.DeltaX = m.TailX * position; m.TailY = ((double)Math.Abs(270 - direction) / 90); m.DeltaY = m.TailY * position; if (_random.NextDouble() >= (double)(360-direction)/100) { m.X = rand() % BufferWi; m.Y = 0; } else { m.X = BufferWi; m.Y = rand() % BufferHt; } } if (MeteorEffect == MeteorsEffect.Explode) { m.X = BufferWi/2; m.Y = BufferHt/2; } else { if (RandomMeteorPosition || frame < PixelCount) { m.X = rand() % BufferWi; m.Y = (BufferHt - 1 - (rand() % tailStart)); } } m.DeltaXOrig = m.DeltaX; m.DeltaYOrig = m.DeltaY; switch (ColorType) { case MeteorsColorType.Range: //Random two colors are selected from the list for each meteor. m.Hsv = SetRangeColor(HSV.FromRGB(Colors[rand()%colorcnt].GetColorAt((GetEffectTimeIntervalPosition(frame)*100)/100)), HSV.FromRGB(Colors[rand()%colorcnt].GetColorAt((GetEffectTimeIntervalPosition(frame)*100)/100))); break; case MeteorsColorType.Palette: //All colors are used m.Hsv = HSV.FromRGB(Colors[rand()%colorcnt].GetColorAt((GetEffectTimeIntervalPosition(frame)*100)/100)); break; case MeteorsColorType.Gradient: m.Color = rand() % colorcnt; _gradientPosition = 100 / (double)tailLength / 100; m.Hsv = HSV.FromRGB(Colors[m.Color].GetColorAt(0)); break; } m.HsvBrightness = RandomBrightness ? _random.NextDouble() * (1.0 - .25) + .25 : 1; _meteors.Add(m); } // render meteors foreach (MeteorClass meteor in _meteors) { meteor.DeltaX += meteor.DeltaXOrig; meteor.DeltaY += meteor.DeltaYOrig; int colorX = (meteor.X + Convert.ToInt32(meteor.DeltaX) - (BufferWi / 100)); int colorY = (meteor.Y + Convert.ToInt32(meteor.DeltaY) + (BufferHt / 100)); for (int ph = 0; ph < tailLength; ph++) { switch (ColorType) { case MeteorsColorType.RainBow: //No user colors are used for Rainbow effect. meteor.Hsv.H = (float) (rand()%1000)/1000.0f; meteor.Hsv.S = 1.0f; meteor.Hsv.V = 1.0f; break; case MeteorsColorType.Gradient: meteor.Hsv = HSV.FromRGB(Colors[meteor.Color].GetColorAt(_gradientPosition*ph)); break; } hsv = meteor.Hsv; hsv.V *= meteor.HsvBrightness; hsv.V *= (float) (1.0 - ((double) ph/tailLength)*0.75); //Adjusts the brightness based on the level curve hsv.V = hsv.V * LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; var decPlaces = (int) (((decimal) (meteor.TailX*ph)%1)*100); if (decPlaces <= 40 || decPlaces >= 60) frameBuffer.SetPixel(colorX - (int) (Math.Round(meteor.TailX*ph)), colorY - (int) (Math.Round(meteor.TailY*ph)), hsv); } if (colorX >= BufferWi + tailLength || colorY >= BufferHt + tailLength || colorX < 0 - tailLength || colorY < 0 - tailLength) { meteor.Expired = true; //flags Meteors that have reached the end of the grid as expiried. // break; } } // delete old meteors int meteorNum = 0; while (meteorNum < _meteors.Count) { if (_meteors[meteorNum].Expired) { _meteors.RemoveAt(meteorNum); } else { meteorNum++; } } }
protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer) { double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; int i, x, y, xc, yc, ColorIdx; int mod1440, d_mod; srand(1); int state = frame*Speed; float R, r, d, d_orig, t; double hyp, x2, y2; HSV hsv = new HSV(); // we will define an hsv color model. int colorcnt = Colors.Count; xc = (int) (BufferWi/2); // 20x100 flex strips with 2 fols per strip = 40x50 yc = (int) (BufferHt/2); R = (float) (xc*(OCR / 100.0)); // Radius of the large circle just fits in the width of model r = (float)(xc * (ICR / 100.0)); // start little circle at 1/4 of max width if (r > R) r = R; d = (float) (xc*(Distance/100.0)); // A hypotrochoid is a roulette traced by a point attached to a circle of radius r rolling around the inside of a fixed circle of radius R, where the point is a distance d from the center of the interior circle. //The parametric equations for a hypotrochoid are:[citation needed] // // more info: http://en.wikipedia.org/wiki/Hypotrochoid // try { mod1440 = Convert.ToInt32(state % 1440); d_orig = d; for (i = 1; i <= SpirographRange * 18; i++) { if (Animate) d = (int)(d_orig + state / 2) % 100; // should we modify the distance variable each pass through? t = (float) ((i + mod1440)*Math.PI/180); x = Convert.ToInt32((R - r)*Math.Cos(t) + d*Math.Cos(((R - r)/r)*t) + xc); y = Convert.ToInt32((R - r)*Math.Sin(t) + d*Math.Sin(((R - r)/r)*t) + yc); if (colorcnt > 0) d_mod = (int)(Range) / colorcnt; else d_mod = 1; x2 = Math.Pow((x - xc), 2); y2 = Math.Pow((y - yc), 2); hyp = Math.Sqrt(x2 + y2) / (Range) * 100.0; switch (Type) { case ColorType.Random: ColorIdx = _random.Next(0, colorcnt); // Select random numbers from 0 up to number of colors the user has added. break; case ColorType.Rainbow: ColorIdx = 1; hsv.H = (float) (rand()%1000)/1000.0f; hsv.S = 1.0f; hsv.V = 1.0f; break; default: ColorIdx = (int)(hyp / d_mod); break; } if (ColorIdx >= colorcnt) ColorIdx = colorcnt - 1; if (Type != ColorType.Rainbow) { hsv = HSV.FromRGB(Colors[ColorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame)*100)/100)); hsv.V = hsv.V*level; } frameBuffer.SetPixel(x, y, hsv); } } catch { } }
protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer) { var overallLevel = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; int colorcnt = Colors.Count; var xc = Math.Max(BufferWi, BufferHt)/2; double pos = (GetEffectTimeIntervalPosition(frame) * Speed * 360); int degreesPerArm = 1; if (Arms > 0) degreesPerArm = 360/Arms; float armsize = (float) (Size/100.0); for (int a = 1; a <= Arms; a++) { var colorIdx = a%colorcnt; switch (ColorType) { case PinWheelColorType.Rainbow: //No user colors are used for Rainbow effect. _hsv.H = Rand(); _hsv.S = 1.0f; _hsv.V = 1.0f; break; case PinWheelColorType.Random: _hsv = HSV.FromRGB(_newColors[colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); break; case PinWheelColorType.Standard: _hsv = HSV.FromRGB(Colors[colorIdx].ColorGradient.GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)); break; } var baseDegrees = Rotation==RotationType.Backward ? (int) ((a + 1)*degreesPerArm + pos) : (int) ((a + 1)*degreesPerArm - pos); _hsv.V = _hsv.V * Colors[colorIdx].Curve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; _hsv.V = _hsv.V * overallLevel; Draw_arm(frameBuffer, baseDegrees, xc * armsize, Twist, _hsv, XOffset, YOffset, frame, colorIdx, overallLevel); //Adjusts arm thickness var tmax = (float)((Thickness / 100.0) * degreesPerArm / 2.0); float t; for (t = 1; t <= tmax; t++) { if (PinWheel3D) { _hsv.V = _hsv.V*((tmax - t)/tmax); } Draw_arm(frameBuffer, baseDegrees - t, xc*armsize, Twist, _hsv, XOffset, YOffset, frame, colorIdx, overallLevel); Draw_arm(frameBuffer, baseDegrees + t, xc*armsize, Twist, _hsv, XOffset, YOffset, frame, colorIdx, overallLevel); } } }
protected override void OnUpdatePlaneImage(Bitmap bmp) { using(Graphics gr=Graphics.FromImage(bmp)) { using(LinearGradientBrush brs=new LinearGradientBrush( new Point(0,0),new Point(1,0), Color.White,Color.White)) { //draw hue brs.Transform=new Matrix((float)bmp.Width,0f,0f,1f,0f,0f); brs.InterpolationColors=GetHueBlend(1.0,_color.V); gr.FillRectangle(brs,new Rectangle(Point.Empty,bmp.Size)); //draw value brs.Transform=new Matrix(0f,(float)bmp.Height,1f,0f,0f,0f); ColorBlend blnd=new ColorBlend(); Color zerosat=new HSV(0.0,0.0,_color.V).ToRGB(); blnd.Colors=new Color[]{Color.FromArgb(0,zerosat),zerosat}; blnd.Positions=new float[]{0f,1f}; brs.InterpolationColors=blnd; gr.FillRectangle(brs,new Rectangle(Point.Empty,bmp.Size)); } } }
// 0,0 is lower left public void SetPixel(int x, int y, HSV hsv) { Color color = hsv.ToRGB().ToArgb(); SetPixel(x, y, color); }
protected override void RenderEffect(int effectFrame, ref PixelFrameBuffer frameBuffer) { int repeat = Repeat; switch (ButterflyType) { case ButterflyType.Type1 : case ButterflyType.Type5: repeat = Repeat*3; break; case ButterflyType.Type4: repeat = Repeat*6; break; } double h=0.0; int maxframe=BufferHt; double position = (GetEffectTimeIntervalPosition(effectFrame) * Iterations) % 1; int curState = (int)(TimeSpan.TotalMilliseconds*position*repeat); int frame = (BufferHt * curState / (int)TimeSpan.TotalMilliseconds) % maxframe; double offset=curState/TimeSpan.TotalMilliseconds; if(Direction==Direction.Forward) offset = -offset; for (int x=0; x<BufferWi; x++) { int y; for (y=0; y<BufferHt; y++) { double n; double x1; double y1; double f; int d; int x0; int y0; switch (ButterflyType) { case ButterflyType.Type1: // http://mathworld.wolfram.com/ButterflyFunction.html n = Math.Abs((x*x - y*y) * Math.Sin(offset + ((x+y)*pi2 / (BufferHt+BufferWi)))); d = x*x + y*y; // This section is to fix the colors on pixels at {0,1} and {1,0} x0=x+1; y0=y+1; if((x==0 && y==1)) { n = Math.Abs((x*x - y0*y0) * Math.Sin (offset + ((x+y0)*pi2 / (BufferHt+BufferWi)))); d = x*x + y0*y0; } if((x==1 && y==0)) { n = Math.Abs((x0*x0 - y*y) * Math.Sin (offset + ((x0+y)*pi2 / (BufferHt+BufferWi)))); d = x0*x0 + y*y; } // end of fix h=d>0.001 ? n/d : 0.0; break; case ButterflyType.Type2: f=(frame < maxframe/2) ? frame+1 : maxframe - frame; x1=(x -BufferWi/2.0)/f; y1=(y-BufferHt/2.0)/f; h=Math.Sqrt(x1*x1+y1*y1); break; case ButterflyType.Type3: f=(frame < maxframe/2) ? frame+1 : maxframe - frame; f=f*0.1+BufferHt/60.0; x1 = (x-BufferWi/2.0)/f; y1 = (y-BufferHt/2.0)/f; h=Math.Sin(x1) * Math.Cos(y1); break; case ButterflyType.Type4: // http://mathworld.wolfram.com/ButterflyFunction.html n = ((x*x - y*y) * Math.Sin (offset + ((x+y)*pi2 / (BufferHt+BufferWi)))); d = x*x + y*y; // This section is to fix the colors on pixels at {0,1} and {1,0} x0=x+1; y0=y+1; if((x==0 && y==1)) { n = ((x*x - y0*y0) * Math.Sin (offset + ((x+y0)*pi2 / (BufferHt+BufferWi)))); d = x*x + y0*y0; } if((x==1 && y==0)) { n = ((x0*x0 - y*y) * Math.Sin (offset + ((x0+y)*pi2 / (BufferHt+BufferWi)))); d = x0*x0 + y*y; } // end of fix h=d>0.001 ? n/d : 0.0; var fractpart = h - (Math.Floor(h)); h=fractpart; if(h<0) h=1.0+h; break; case ButterflyType.Type5: // http://mathworld.wolfram.com/ButterflyFunction.html n = Math.Abs((x*x - y*y) * Math.Sin (offset + ((x+y)*pi2 / (BufferHt*BufferWi)))); d = x*x + y*y; // This section is to fix the colors on pixels at {0,1} and {1,0} x0=x+1; y0=y+1; if((x==0 && y==1)) { n = Math.Abs((x*x - y0*y0) * Math.Sin (offset + ((x+y0)*pi2 / (BufferHt*BufferWi)))); d = x*x + y0*y0; } if((x==1 && y==0)) { n = Math.Abs((x0*x0 - y*y) * Math.Sin (offset + ((x0+y)*pi2 / (BufferHt*BufferWi)))); d = x0*x0 + y*y; } // end of fix h=d>0.001 ? n/d : 0.0; break; } HSV hsv = new HSV(h, 1.0, 1.0); double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(effectFrame) * 100) / 100; if (BackgroundChunks <= 1 || (int)(h*BackgroundChunks) % BackgroundSkips != 0) { if (ColorScheme == ColorScheme.Gradient) { Color color = Color.GetColorAt(h); hsv = HSV.FromRGB(color); } hsv.V = hsv.V * level; frameBuffer.SetPixel(x, y, hsv); } } } }
public static HSV FromRGB(double r, double g, double b) { double min = Math.Min(Math.Min(r, g), b), max = Math.Max(Math.Max(r, g), b), delta_max = max - min; HSV ret = new HSV(0, 0, 0); ret._v = max; if (delta_max == 0.0) { ret._h = 0.0; ret._s = 0.0; } else { ret._s = delta_max / max; double del_R = (((max - r) / 6.0) + (delta_max / 2.0)) / delta_max; double del_G = (((max - g) / 6.0) + (delta_max / 2.0)) / delta_max; double del_B = (((max - b) / 6.0) + (delta_max / 2.0)) / delta_max; if (r == max) ret._h = del_B - del_G; else if (g == max) ret._h = (1.0 / 3.0) + del_R - del_B; else if (b == max) ret._h = (2.0 / 3.0) + del_G - del_R; if (ret._h < 0.0) ret._h += 1.0; if (ret._h > 1.0) ret._h -= 1.0; } return ret; }
private void Draw_arm(IPixelFrameBuffer frameBuffer, float baseDegrees, float maxRadius, int twist, HSV hsv, int xOffset, int yOffset, int frame, int colorIdx, double overallLevel) { int xc = BufferWi/2; int yc = BufferHt/2; xc = (int)(xc + (xOffset / 100.0) * xc); // XOffset is from -100 to 100 yc = (int)(yc + (yOffset / 100.0) * yc); for (double r = 0.0; r <= maxRadius; r += 0.5) { int degreesTwist = (int) ((r/maxRadius)*twist); int degrees = (int)(baseDegrees + degreesTwist); double phi = degrees*Pi180; int x = (int) (r*Math.Cos(phi) + xc); int y = (int) (r*Math.Sin(phi) + yc); switch (ColorType) { case PinWheelColorType.Gradient: //Applies gradient over each arm hsv = HSV.FromRGB(maxRadius > (double)(Math.Max(BufferHt, BufferWi)) / 2 ? Colors[colorIdx].ColorGradient.GetColorAt((100 / ((double)(Math.Max(BufferHt, BufferWi)) / 2) * r) / 100) : Colors[colorIdx].ColorGradient.GetColorAt((100 / maxRadius * r) / 100)); hsv.V = hsv.V * Colors[colorIdx].Curve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100; hsv.V = hsv.V * overallLevel; break; } if (r > CenterStart) frameBuffer.SetPixel(x, y, hsv); } }
protected override void SetupRender() { if (ColorType == PinWheelColorType.Random) { HSV temphsv = new HSV(); _newColors = new List<ColorGradient>(); for (int newColr = 0; newColr < Arms; newColr++) { temphsv.H = Rand(); temphsv.S = 1.0f; temphsv.V = 1.0f; _newColors.Add(new ColorGradient(temphsv.ToRGB())); } } }
/// <summary> /// Update a existing pixel in the specified frame. The pixel must exist from either the InitializeNextFrame /// or the SetPixel methods or an exception will occur. /// </summary> /// <param name="frame"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="hsv"></param> public void UpdatePixel(int frame, int x, int y, HSV hsv) { var color = hsv.ToRGB(); UpdatePixel(frame, x, y, color); }
/// <summary> /// Add a frame and set the pixel to the given color. This cannot be used to update a pixel that /// has already been set. See update functions. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="hsv"></param> public void SetPixel(int x, int y, HSV hsv) { var color = hsv.ToRGB(); SetPixel(x, y, color); }
public LightingValue(Color color) { hsv = HSV.FromRGB(color); }
private HSV CustomColor(HSV hsv, int frame, double level, Color fpColor) { if (ColorEffect == ColorEffect.CustomColor) { Color newColor = new Color(); newColor = _data.Colors.GetColorAt((GetEffectTimeIntervalPosition(frame)*100)/100); double hsvLevel = Convert.ToInt32(fpColor.GetBrightness()*255); hsv = HSV.FromRGB(newColor); hsv.V = hsvLevel/100; } double tempV = hsv.V*level*((double) (IncreaseBrightness)/10); if (tempV > 1) tempV = 1; hsv.V = tempV; return hsv; }
public LightingValue(double h, double s, double i) { hsv = new HSV(h, s, i); }
public static HSV FromRGB(RGB col) { double min = Math.Min( Math.Min(col.R,col.G),col.B), max = Math.Max( Math.Max(col.R,col.G),col.B), delta_max = max-min; HSV ret=new HSV(0,0,0); ret._v=max; if (delta_max==0.0) { ret._h=0.0; ret._s=0.0; } else { ret._s=delta_max/max; double del_R=(((max-col.R)/6.0)+(delta_max/2.0))/delta_max; double del_G=(((max-col.G)/6.0)+(delta_max/2.0))/delta_max; double del_B=(((max-col.B)/6.0)+(delta_max/2.0))/delta_max; if (col.R==max) ret._h = del_B-del_G; else if (col.G==max) ret._h = (1.0/3.0)+del_R-del_B; else if (col.B==max) ret._h = (2.0/3.0)+del_G-del_R; if (ret._h<0.0)ret._h+=1.0; if (ret._h>1.0)ret._h-=1.0; } return ret; }
private void CreateExplosions(int ii, int x75, int x25, int y75, int y25) { HSV hsv = new HSV(); if (ColorType == FireworksColorType.Random) { hsv.H = (float)(Rand() % 1000) / 1000.0f; hsv.S = 1.0f; hsv.V = 1.0f; } int start = EnableAudio ? ii : (int) (Rand01()*GetNumberFrames()); int startX; int startY; if ((x75 - x25) > 0) startX = x25 + Rand() % (x75 - x25); else startX = 0; if ((y75 - y25) > 0) startY = y25 + Rand() % (y75 - y25); else startY = 0; int colorLocation = Rand() % ColorGradients.Count; int randomParticles = RandomParticles ? _random.Next(MinParticles, MaxParticles) : Particles; for (int i = 0; i < randomParticles; i++) { int velocity = RandomVelocity ? _random.Next(MinVelocity, MaxVelocity) : Velocity; _fireworkBursts[_explosion * randomParticles + i].Reset(startX, startY, false, velocity, hsv, start, colorLocation); } }