예제 #1
0
파일: SnowStorm.cs 프로젝트: Aurbo99/vixen
		private void SnowstormAdvance(SnowstormClass ssItem)
		{
			const int cnt = 8; // # of integers in each set in arr[]
			int[] arr = { 30, 20, 10, 5, 0, 5, 10, 20, 20, 15, 10, 10, 10, 10, 10, 15 };
			// 2 sets of 8 numbers, each of which add up to 100
			Point adv = SnowstormVector(7);
			int i0 = ssItem.Idx % 7 <= 4 ? 0 : cnt;
			int r = rand() % 100;
			for (int i = 0, val = 0; i < cnt; i++)
			{
				val += arr[i0 + i];
				if (r < val)
				{
					adv = SnowstormVector(i);
					break;
				}
			}
			if (ssItem.Idx % 3 == 0)
			{
				adv.X *= 2;
				adv.Y *= 2;
			}
			Point xy = ssItem.Points[ssItem.Points.Count - 1];
			xy.X += adv.X;
			xy.Y += adv.Y;

			xy.X %= BufferWi;
			xy.Y %= BufferHt;
			if (xy.X < 0) xy.X += BufferWi;
			if (xy.Y < 0) xy.Y += BufferHt;
			ssItem.Points.Add(xy);
		}
예제 #2
0
        private void InitializeSnowstorm()
        {
            if (_palette == null)
            {
                return;
            }

            var hsv0 = _palette[0].ToHSV();
            var hsv1 = (_palette.Length > 1 ? _palette[1] : _palette[0]).ToHSV();

            var count      = Convert.ToInt32(_bufferWidth * _bufferHeight * tbMaxFlakes.Value / 2000) + 1;
            var tailLength = _bufferWidth * _bufferHeight * tbTailLength.Value / 2000 + 2;
            var xy         = new Point();

            // create snowstorm elements
            _snowstormItems.Clear();
            for (var i = 0; i < count; i++)
            {
                var ssItem = new SnowstormClass {
                    Idx = i, SsDecay = 0
                };
                ssItem.Points.Clear();
                ssItem.HSV = hsv0.CreateRangeTo(hsv1);
                // start in a random state
                var r = Rand() % (2 * tailLength);
                if (r > 0)
                {
                    xy.X = Rand() % _bufferWidth;
                    xy.Y = Rand() % _bufferHeight;
                    //ssItem.points.push_back(xy);
                    ssItem.Points.Add(xy);
                }
                if (r >= tailLength)
                {
                    ssItem.SsDecay = r - tailLength;
                    r = tailLength;
                }
                for (var j = 1; j < r; j++)
                {
                    SnowstormAdvance(ssItem);
                }
                //SnowstormItems.push_back(ssItem);
                _snowstormItems.Add(ssItem);
            }
        }
예제 #3
0
        private void SnowstormAdvance(SnowstormClass ssItem)
        {
            const int cnt = 8;                                                           // # of integers in each set in arr[]

            int[] arr = { 30, 20, 10, 5, 0, 5, 10, 20, 20, 15, 10, 10, 10, 10, 10, 15 }; // 2 sets of 8 numbers, each of which add up to 100
            var   adv = SnowstormVector(7);
            var   i0  = ssItem.Idx % 7 <= 4 ? 0 : cnt;
            var   r   = Rand() % 100;

            for (int i = 0, val = 0; i < cnt; i++)
            {
                val += arr[i0 + i];
                if (r >= val)
                {
                    continue;
                }
                adv = SnowstormVector(i);
                break;
            }
            if (ssItem.Idx % 3 == 0)
            {
                adv.X *= 2;
                adv.Y *= 2;
            }
            //Point xy = ssItem.points.back() + adv;
            var xy = ssItem.Points[ssItem.Points.Count - 1];

            xy.X += adv.X;
            xy.Y += adv.Y;

            xy.X %= _bufferWidth;
            xy.Y %= _bufferHeight;
            if (xy.X < 0)
            {
                xy.X += _bufferWidth;
            }
            if (xy.Y < 0)
            {
                xy.Y += _bufferHeight;
            }
            //ssItem.points.push_back(xy);
            ssItem.Points.Add(xy);
        }
예제 #4
0
        private void SnowstormAdvance(SnowstormClass ssItem)
        {
            const int cnt = 8; // # of integers in each set in arr[]
            int[] arr = {30, 20, 10, 5, 0, 5, 10, 20, 20, 15, 10, 10, 10, 10, 10, 15};
            // 2 sets of 8 numbers, each of which add up to 100
            Point adv = SnowstormVector(7);
            int i0 = ssItem.idx%7 <= 4 ? 0 : cnt;
            int r = rand()%100;
            for (int i = 0, val = 0; i < cnt; i++) {
                val += arr[i0 + i];
                if (r < val) {
                    adv = SnowstormVector(i);
                    break;
                }
            }
            if (ssItem.idx%3 == 0) {
                adv.X *= 2;
                adv.Y *= 2;
            }
            //Point xy = ssItem.points.back() + adv;
            Point xy = ssItem.points[ssItem.points.Count - 1];
            xy.X += adv.X;
            xy.Y += adv.Y;

            xy.X %= BufferWi;
            xy.Y %= BufferHt;
            if (xy.X < 0) xy.X += BufferWi;
            if (xy.Y < 0) xy.Y += BufferHt;
            //ssItem.points.push_back(xy);
            ssItem.points.Add(xy);
        }
예제 #5
0
        public void RenderSnowstorm(int Count, int Length)
        {
            HSV hsv, hsv0, hsv1;
            hsv0 = Palette.GetHSV(0);
            hsv1 = Palette.GetHSV(1);
            int colorcnt = GetColorCount();
            Count = Convert.ToInt32(BufferWi*BufferHt*Count/2000) + 1;
            int TailLength = BufferWi*BufferHt*Length/2000 + 2;
            SnowstormClass ssItem;
            Point xy = new Point();
            int r;
            if (State == 0 || Count != LastSnowstormCount) {
                // create snowstorm elements
                LastSnowstormCount = Count;
                SnowstormItems.Clear();
                for (int i = 0; i < Count; i++) {
                    ssItem = new SnowstormClass();
                    ssItem.idx = i;
                    ssItem.ssDecay = 0;
                    ssItem.points.Clear();
                    ssItem.hsv = HSV.SetRangeColor(hsv0, hsv1);
                    // start in a random state
                    r = rand()%(2*TailLength);
                    if (r > 0) {
                        xy.X = rand()%BufferWi;
                        xy.Y = rand()%BufferHt;
                        //ssItem.points.push_back(xy);
                        ssItem.points.Add(xy);
                    }
                    if (r >= TailLength) {
                        ssItem.ssDecay = r - TailLength;
                        r = TailLength;
                    }
                    for (int j = 1; j < r; j++) {
                        SnowstormAdvance(ssItem);
                    }
                    //SnowstormItems.push_back(ssItem);
                    SnowstormItems.Add(ssItem);
                }
            }

            // render Snowstorm Items
            int sz;
            //int cnt = 0;
            //for (SnowstormList::iterator it = SnowstormItems.begin(); it != SnowstormItems.end(); ++it)
            foreach (SnowstormClass it in SnowstormItems) {
                if (it.points.Count() > TailLength) {
                    if (it.ssDecay > TailLength) {
                        it.points.Clear(); // start over
                        it.ssDecay = 0;
                    }
                    else if (rand()%20 < Data.Speed) {
                        it.ssDecay++;
                    }
                }
                if (it.points.Count == 0) {
                    xy.X = rand()%BufferWi;
                    xy.Y = rand()%BufferHt;
                    //it.points.push_back(xy);
                    it.points.Add(xy);
                }
                else if (rand()%20 < Data.Speed) {
                    SnowstormAdvance(it);
                }
                sz = it.points.Count();
                for (int pt = 0; pt < sz; pt++) {
                    hsv = it.hsv;
                    hsv.Value = (float) (1.0 - (double) (sz - pt + it.ssDecay)/TailLength);
                    if (hsv.Value < 0.0) hsv.Value = 0.0f;
                    SetPixel(it.points[pt].X, it.points[pt].Y, hsv);
                }
                //cnt++;
            }
        }
예제 #6
0
파일: SnowStorm.cs 프로젝트: Aurbo99/vixen
		protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
		{
			int colorcnt = Colors.Count;
			var intervalPos = GetEffectTimeIntervalPosition(frame);
			var intervalPosFactor = intervalPos * 100;
			var adjustSpeed = CalculateSpeed(intervalPosFactor);
			int count = Convert.ToInt32(BufferWi * BufferHt * CalculateCount(intervalPosFactor) / 2000) + 1;
			int tailLength = (int)Math.Round(BufferWi * BufferHt * CalculateLength(intervalPosFactor) / 2000 + 2);
			double level = LevelCurve.GetValue(intervalPosFactor) / 100;
			Point xy = new Point();
			int r;
			if (frame == 0)
			{
				_snowstormItems.Clear();
			}
			// create snowstorm elements
			for (int i = 0; i < count; i++)
			{
				if (_snowstormItems.Count < count)
				{
					var ssItem = new SnowstormClass();
					ssItem.Idx = i;
					ssItem.SsDecay = 0;
					ssItem.Points.Clear();
					switch (ColorType)
					{
						case SnowStormColorType.Range: //Random two colors are selected from the list for each Snowstorms.
							ssItem.Hsv =
								SetRangeColor(HSV.FromRGB(Colors[rand() % colorcnt].GetColorAt((intervalPosFactor) / 100)),
									HSV.FromRGB(Colors[rand() % colorcnt].GetColorAt((intervalPosFactor) / 100)));
							break;
						case SnowStormColorType.Palette: //All colors are used
							ssItem.Hsv = HSV.FromRGB(Colors[rand() % colorcnt].GetColorAt((intervalPosFactor) / 100));
							break;
						case SnowStormColorType.Gradient:
							ssItem.Color = rand()%colorcnt;
							_gradientPosition = 100/(double) tailLength/100;
							ssItem.Hsv = HSV.FromRGB(Colors[ssItem.Color].GetColorAt(0));
							break;
					}
					// start in a random state
					r = rand()%(2*tailLength);
					if (r > 0)
					{
						xy.X = rand()%BufferWi;
						xy.Y = rand()%BufferHt;
						//ssItem.points.push_back(xy);
						ssItem.Points.Add(xy);
					}
					if (r >= tailLength)
					{
						ssItem.SsDecay = r - tailLength;
						r = tailLength;
					}
					for (int j = 1; j < r; j++)
					{
						SnowstormAdvance(ssItem);
					}
					_snowstormItems.Add(ssItem);
				}
			}

			// render Snowstorm Items
			foreach (SnowstormClass it in _snowstormItems)
			{
				if (it.Points.Count == 0)
				{
					xy.X = rand() % BufferWi;
					xy.Y = rand() % BufferHt;
					it.Points.Add(xy);
				}
				else if (rand() % 20 < adjustSpeed)
				{
					SnowstormAdvance(it);
				}
				var sz = it.Points.Count();
				for (int pt = 0; pt < sz; pt++)
				{
					switch (ColorType)
					{
						case SnowStormColorType.RainBow: //No user colors are used for Rainbow effect.
							it.Hsv.H = (float)(rand() % 1000) / 1000.0f;
							it.Hsv.S = 1.0f;
							it.Hsv.V = 1.0f;
							break;
						case SnowStormColorType.Gradient:
							it.Hsv = HSV.FromRGB(Colors[it.Color].GetColorAt(_gradientPosition * pt));
							break;
					}
					var hsv = it.Hsv;
					hsv.V = (float)(1.0 - (double)(sz - pt + it.SsDecay) / tailLength);
					hsv.V *= level;
					if (it.Points[pt].X >= BufferWi - 1 || it.Points[pt].Y >= BufferHt - 1 || it.Points[pt].X <= 1 || it.Points[pt].Y <= 1)
					{
						it.Expired = true; //flags Snowstorms that have reached the end of the grid as expiried.
						break;
					}
					if (hsv.V < 0.0) hsv.V = 0.0f;
					if (!ReverseDirection)
					{
						frameBuffer.SetPixel(it.Points[pt].X, it.Points[pt].Y, hsv);
					}
					else
					{
						frameBuffer.SetPixel(BufferWi - it.Points[pt].X, it.Points[pt].Y, hsv);
					}
				}
			}
			// delete old Snowstorms
			int snowStorms = 0;
			while (snowStorms < _snowstormItems.Count)
			{
				if (_snowstormItems[snowStorms].Expired)
				{
					_snowstormItems.RemoveAt(snowStorms);
				}
				else
				{
					snowStorms++;
				}
			}
		}
예제 #7
0
파일: Snowstorm.cs 프로젝트: jmcadams/vplus
        private void SnowstormAdvance(SnowstormClass ssItem)
        {
            const int cnt = 8; // # of integers in each set in arr[]
            int[] arr = {30, 20, 10, 5, 0, 5, 10, 20, 20, 15, 10, 10, 10, 10, 10, 15}; // 2 sets of 8 numbers, each of which add up to 100
            var adv = SnowstormVector(7);
            var i0 = ssItem.Idx % 7 <= 4 ? 0 : cnt;
            var r = Rand() % 100;
            for (int i = 0, val = 0; i < cnt; i++) {
                val += arr[i0 + i];
                if (r >= val) {
                    continue;
                }
                adv = SnowstormVector(i);
                break;
            }
            if (ssItem.Idx % 3 == 0) {
                adv.X *= 2;
                adv.Y *= 2;
            }
            //Point xy = ssItem.points.back() + adv;
            var xy = ssItem.Points[ssItem.Points.Count - 1];
            xy.X += adv.X;
            xy.Y += adv.Y;

            xy.X %= _bufferWidth;
            xy.Y %= _bufferHeight;
            if (xy.X < 0) {
                xy.X += _bufferWidth;
            }
            if (xy.Y < 0) {
                xy.Y += _bufferHeight;
            }
            //ssItem.points.push_back(xy);
            ssItem.Points.Add(xy);
        }
예제 #8
0
파일: Snowstorm.cs 프로젝트: jmcadams/vplus
        private void InitializeSnowstorm()
        {
            if (_palette == null) return;

            var hsv0 = _palette[0].ToHSV();
            var hsv1 = (_palette.Length > 1 ? _palette[1] : _palette[0]).ToHSV();

            var count = Convert.ToInt32(_bufferWidth * _bufferHeight * tbMaxFlakes.Value / 2000) + 1;
            var tailLength = _bufferWidth * _bufferHeight * tbTailLength.Value / 2000 + 2;
            var xy = new Point();
            // create snowstorm elements
            _snowstormItems.Clear();
            for (var i = 0; i < count; i++) {
                var ssItem = new SnowstormClass {Idx = i, SsDecay = 0};
                ssItem.Points.Clear();
                ssItem.HSV = hsv0.CreateRangeTo(hsv1);
                // start in a random state
                var r = Rand() % (2 * tailLength);
                if (r > 0) {
                    xy.X = Rand() % _bufferWidth;
                    xy.Y = Rand() % _bufferHeight;
                    //ssItem.points.push_back(xy);
                    ssItem.Points.Add(xy);
                }
                if (r >= tailLength) {
                    ssItem.SsDecay = r - tailLength;
                    r = tailLength;
                }
                for (var j = 1; j < r; j++) {
                    SnowstormAdvance(ssItem);
                }
                //SnowstormItems.push_back(ssItem);
                _snowstormItems.Add(ssItem);
            }
        }