示例#1
0
        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);
                }
            }
        }
示例#2
0
        private void CalculatePixel(int x, int y, IPixelFrameBuffer frameBuffer, int thickness, int topThickness, int bottomThickness, int leftThickness, int rightThickness, double intervalPosFactor, double level, int effectFrame, double borderWidth, Color color)
        {
            int yCoord = y;
            int xCoord = x;

            if (TargetPositioning == TargetPositioningType.Locations)
            {
                //Flip me over so and offset my coordinates I can act like the string version
                y = Math.Abs((BufferHtOffset - y) + (BufferHt - 1 + BufferHtOffset));
                y = y - BufferHtOffset;
                x = x - BufferWiOffset;
            }

            if (BorderType == BorderType.Single || BorderMode == BorderMode.Simple)            //Single Border Control
            {
                //Displays borders
                if ((y < borderWidth + thickness || y >= BufferHt - borderWidth - thickness || x < borderWidth + thickness || x >= BufferWi - borderWidth - thickness) &&
                    x >= borderWidth && y < BufferHt - borderWidth && y >= borderWidth && x < BufferWi - borderWidth)
                {
                    color = GetColor(x, y, color, level);
                    frameBuffer.SetPixel(xCoord, yCoord, color);
                }
            }
            else
            {
                //Displays Independent Borders
                if ((y < borderWidth + bottomThickness || y >= BufferHt - borderWidth - topThickness || x < borderWidth + leftThickness || x >= BufferWi - borderWidth - rightThickness) &&
                    x >= borderWidth && y < BufferHt - borderWidth && y >= borderWidth && x < BufferWi - borderWidth)
                {
                    color = GetColor(x, y, color, level);
                    frameBuffer.SetPixel(xCoord, yCoord, color);
                }
            }
        }
示例#3
0
        /// <inheritdoc />
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            var    intervalPos       = GetEffectTimeIntervalPosition(frame);
            var    intervalPosFactor = intervalPos * 100;
            double level             = LevelCurve.GetValue(intervalPosFactor) / 100;

            if (_fp != null)
            {
                int yoffset = (BufferHt + _fp.Height) / 2;
                int xoffset = (_fp.Width - BufferWi) / 2;

                for (int x = 0; x < _fp.Width; x++)
                {
                    for (int y = 0; y < _fp.Height; y++)
                    {
                        var fpColor = _fp.GetPixel(x, y);

                        var hsv = HSV.FromRGB(fpColor);
                        hsv.V = hsv.V * level;

                        frameBuffer.SetPixel(x - xoffset, yoffset - y, hsv);
                    }
                }
            }
        }
示例#4
0
文件: Text.cs 项目: gnarmstr/Vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            var bufferHt = BufferHt;
            var bufferWi = BufferWi;

            using (var bitmap = new Bitmap(bufferWi, bufferHt))
            {
                InitialRender(frame, bitmap, bufferHt, bufferWi);
                if (_text.Count == 0 && !UseBaseColor)
                {
                    return;
                }
                _level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
                FastPixel.FastPixel fp = new FastPixel.FastPixel(bitmap);
                fp.Lock();
                // copy to frameBuffer
                for (int x = 0; x < bufferWi; x++)
                {
                    for (int y = 0; y < bufferHt; y++)
                    {
                        CalculatePixel(x, y, ref bufferHt, fp, frameBuffer);
                    }
                }
                fp.Unlock(false);
                fp.Dispose();
            }
        }
示例#5
0
文件: Balls.cs 项目: bedwar14/Vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            _intervalPos       = (float)GetEffectTimeIntervalPosition(frame);
            _intervalPosFactor = _intervalPos * 100;

            _radius         = CalculateSize(_intervalPosFactor);
            _centerSpeed    = CalculateCenterSpeed(_intervalPosFactor);
            _speedVariation = CalculateSpeedVariation(_intervalPosFactor);
            _level          = LevelCurve.GetValue(_intervalPosFactor) / 100;
            int   maxRandomTime    = CalculateRandomMax(_intervalPosFactor);
            Color inverseBackColor = BackgroundColor.GetColorAt(_intervalPos);

            double minSpeed = _centerSpeed - (_speedVariation / 2);
            double maxSpeed = _centerSpeed + (_speedVariation / 2);

            _ballCount = CalculateBallCount(_intervalPosFactor);

            // Create new Balls and add balls due to increase in ball count curve.
            CreateBalls(minSpeed, maxSpeed, maxRandomTime);

            // Update Ball location, radius and speed.
            UpdateBalls(minSpeed, maxSpeed, maxRandomTime);

            //Remove Excess Balls due to BallCount Curve.
            RemoveBalls();

            //Iterate through all grid locations.
            for (int y = 0; y < _bufferHt; y++)
            {
                for (int x = 0; x < _bufferWi; x++)
                {
                    CalculatePixel(x, y, frameBuffer, inverseBackColor);
                }
            }
        }
示例#6
0
        protected override void SetupRender()
        {
            _maxGroundHeight  = 0;
            _xSpeedAdjustment = 1;
            _ySpeedAdjustment = 1;
            _wobbleAdjustment = 1;

            if (EnableGroundLevel)
            {
                _tempBuffer = new PixelFrameBuffer(BufferWi + 10, BufferHt + 10);
                for (int x = 0; x < BufferWi; x++)
                {
                    for (int y = 0; y < CalculateGroundLevel(((double)100 / BufferWi) * x); y++)
                    {
                        _tempBuffer.SetPixel(x, y, GroundColor.GetColorAt(0));
                        int temp = (int)CalculateGroundLevel(y);
                        if (temp > _maxGroundHeight)
                        {
                            _maxGroundHeight = temp;
                        }
                    }
                }
            }

            _meteors       = new List <MeteorClass>(32);
            _maxBufferSize = Math.Max(BufferHt / 2, BufferWi / 2);
        }
示例#7
0
        protected override void RenderEffect(int effectFrame, IPixelFrameBuffer frameBuffer)
        {
            int    repeat   = ConfigureRepeat();
            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;
            double level    = LevelCurve.GetValue(GetEffectTimeIntervalPosition(effectFrame) * 100) / 100;


            if (Direction == Direction.Forward)
            {
                offset = -offset;
            }

            int bufferDim = 0;

            if (ButterflyType == ButterflyType.Type1 || ButterflyType == ButterflyType.Type4)
            {
                bufferDim = BufferHt + BufferWi;
            }
            else if (ButterflyType == ButterflyType.Type5)
            {
                bufferDim = BufferHt * BufferWi;
            }
            for (int x = 0; x < BufferWi; x++)
            {
                for (int y = 0; y < BufferHt; y++)
                {
                    CalculatePixel(x, y, bufferDim, offset, frame, maxframe, level, frameBuffer);
                }
            }
        }
示例#8
0
        private void DrawCurtain(bool leftEdge, int xlimit, List <int> swagArray, IPixelFrameBuffer frameBuffer, double level, int width)
        {
            int i, x, y;

            for (i = 0; i < xlimit; i++)
            {
                HSV hsv = HSV.FromRGB(Color.GetColorAt((double)i / width));
                x = leftEdge ? BufferWi - i - 1 : i;
                for (y = BufferHt - 1; y >= 0; y--)
                {
                    hsv.V = hsv.V * level;
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }

            // swag
            for (i = 0; i < swagArray.Count; i++)
            {
                x = xlimit + i;
                HSV hsv = HSV.FromRGB(Color.GetColorAt((double)x / width));
                if (leftEdge)
                {
                    x = BufferWi - x - 1;
                }
                for (y = BufferHt - 1; y > swagArray[i]; y--)
                {
                    hsv.V = hsv.V * level;
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }
        }
示例#9
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (Shimmer && frame % 2 != 0)
            {
                return;
            }
            double level          = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
            int    totalFrames    = GetNumberFrames();
            var    iterationFrame = frame * Iterations % (totalFrames);
            double position       = GetEffectTimeIntervalPosition(iterationFrame);
            HSV    hsv            = HSV.FromRGB(Color.GetColorAt(position));

            for (int x = 0; x < BufferWi; x++)
            {
                for (int y = 0; y < BufferHt; y++)
                {
                    var v = hsv.V;
                    v  = CalculateAdjustedV(v, x, y);
                    v *= level;
                    HSV hsv2 = hsv;
                    hsv2.V = v;
                    frameBuffer.SetPixel(x, y, hsv2);
                }
            }
        }
示例#10
0
        /// <inheritdoc />
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            var intervalPosFactor = ((double)100 / EffectEndTime.TotalMilliseconds) * (StartTime.TotalMilliseconds + frame * 50);
            var yOffsetAdjust     = CalculateYOffset(intervalPosFactor);
            var xOffsetAdjust     = CalculateXOffset(intervalPosFactor);

            if (_fp != null)
            {
                int yoffset = (int)(((double)(BufferHt + _fp.Height) / 2) + yOffsetAdjust - 1);
                int xoffset = (int)(xOffsetAdjust + ((double)BufferWi - _fp.Width) / 2);

                for (int x = 0; x < _fp.Width; x++)
                {
                    for (int y = 0; y < _fp.Height; y++)
                    {
                        var fpColor = _fp.GetPixel(x, y);

                        if (Level < 100)
                        {
                            var hsv = HSV.FromRGB(fpColor);
                            hsv.V   = hsv.V * ((double)Level / 100);
                            fpColor = hsv.ToRGB();
                        }
                        frameBuffer.SetPixel(x + xoffset, yoffset - y, fpColor);
                    }
                }
            }
        }
示例#11
0
        private void CalculatePixel(int x, int y, Bitmap bitmap, double level, IPixelFrameBuffer frameBuffer)
        {
            int yCoord = y;
            int xCoord = x;

            if (TargetPositioning == TargetPositioningType.Locations)
            {
                //Flip me over so and offset my coordinates I can act like the string version
                y = Math.Abs((BufferHtOffset - y) + (BufferHt - 1 + BufferHtOffset));
                y = y - BufferHtOffset;
                x = x - BufferWiOffset;
            }
            Color color = bitmap.GetPixel(x, BufferHt - y - 1);

            if (!EmptyColor.Equals(color))
            {
                var hsv = HSV.FromRGB(color);
                hsv.V = hsv.V * level;

                frameBuffer.SetPixel(xCoord, yCoord, hsv);
            }
            else if (TargetPositioning == TargetPositioningType.Locations)
            {
                //Set me to my base color or transparent
                frameBuffer.SetPixel(xCoord, yCoord, UseBaseColor ? BaseColor : Color.Transparent);
            }
        }
示例#12
0
文件: PinWheel.cs 项目: Aurbo99/vixen
        private void RenderPoint(IPixelFrameBuffer frameBuffer, double twist, int x, int y, Point origin, double maxRadius, List <Tuple <int, HSV> > arms, double angleRange, double overallLevel, bool invertY, double centerStartPct)
        {
            var radius = DistanceFromPoint(origin, x, y);

            if (radius > maxRadius || radius <= (centerStartPct * maxRadius))
            {
                return;
            }
            var angle = GetAngleDegree(origin, x, y);

            double degreesTwist = radius / maxRadius * twist;

            for (int i = 0; i < arms.Count; i++)
            {
                double degrees = AddDegrees(arms[i].Item1, degreesTwist);

                if (IsAngleBetween(AddDegrees(degrees, -angleRange), AddDegrees(degrees, angleRange), angle))
                {
                    HSV hsv;
                    if (ColorType == PinWheelColorType.Gradient)
                    {
                        var colorIdx = i % Colors.Count;
                        hsv   = HSV.FromRGB(Colors[colorIdx].ColorGradient.GetColorAt(radius / maxRadius));
                        hsv.V = hsv.V * Colors[colorIdx].Curve.GetValue(radius / maxRadius * 100) / 100;
                        hsv.V = hsv.V * overallLevel;
                    }
                    else
                    {
                        hsv = arms[i].Item2;
                    }

                    switch (PinWheelBladeType)
                    {
                    case PinWheelBladeType.ThreeD:
                        hsv.V = hsv.V * (1 - (DegreesDiffernce(degrees, angle) / angleRange));
                        break;

                    case PinWheelBladeType.Inverted3D:
                        hsv.V = hsv.V * (DegreesDiffernce(degrees, angle) / angleRange);
                        break;

                    case PinWheelBladeType.Fan:
                        var frontAngle = Rotation == RotationType.Forward ? angleRange : -angleRange;
                        hsv.V = hsv.V * (DegreesDiffernce(AddDegrees(degrees, frontAngle), angle) / (2 * angleRange));
                        break;
                    }

                    if (invertY)
                    {
                        frameBuffer.SetPixel(x, BufferHt - 1 - y, hsv);
                    }
                    else
                    {
                        frameBuffer.SetPixel(x, y, hsv);
                    }
                }
            }
        }
示例#13
0
文件: Circles.cs 项目: bedwar14/Vixen
        private void CalculatePixel(int x, int y, double level, IPixelFrameBuffer frameBuffer, double intervalPos, double radius, double radius1, double currentRadius, double foffset, double barht, double blockHt, int bufferWi, int bufferHt, int xOffset, int yOffset, double edgeWidth)
        {
            int yCoord = y;
            int xCoord = x;

            if (TargetPositioning == TargetPositioningType.Locations)
            {
                //Flip me over so and offset my coordinates I can act like the string version
                y = Math.Abs((BufferHtOffset - y) + (bufferHt - 1 + BufferHtOffset));
                y = y - BufferHtOffset;
                x = x - BufferWiOffset;
            }

            //This saves going through all X and Y locations significantly reducing render times.
            if ((y >= ((bufferWi - 1) / 2) + radius1 + 1 || y <= ((bufferWi - 1) / 2) - radius1) && (x >= ((bufferWi - 1) / 2) + radius1 + 1 || x <= ((bufferWi - 1) / 2) - radius1))
            {
                return;
            }

            double distanceFromBallCenter = DistanceFromPoint(new Point((bufferWi - 1) / 2, (bufferHt - 1) / 2), x + xOffset, y + yOffset);

            int distance = distanceFromBallCenter > 1.4 && distanceFromBallCenter < 1.51
                                ? 2
                                : (int)Math.Round(distanceFromBallCenter);

            radius = (radius * _circleCount);
            bool finished = false;

            switch (CircleRadialDirection)
            {
            case CircleRadialDirection.In:
                for (int i = 0; i <= _circleCount; i++)
                {
                    finished = SetFramePixel(i, foffset, blockHt, barht, intervalPos, level, frameBuffer, xCoord, yCoord,
                                             distance, radius, currentRadius, radius1, edgeWidth);
                    if (finished)
                    {
                        return;
                    }
                    radius = radius - currentRadius;
                }
                break;

            case CircleRadialDirection.Out:
                for (int i = (int)_circleCount; i >= 0; i--)
                {
                    finished = SetFramePixel(i, foffset, blockHt, barht, intervalPos, level, frameBuffer, xCoord, yCoord,
                                             distance, radius, currentRadius, radius1, edgeWidth);
                    if (finished)
                    {
                        return;
                    }
                    radius = radius - currentRadius;
                }
                break;
            }
        }
示例#14
0
        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);
                }
            }
        }
示例#15
0
文件: Garlands.cs 项目: robness/Vixen
        void DrawGarlandPattern(
            IList <Tuple <int, int[]> > sparseMatrix,
            int height,
            int pixelSpacing,
            double brightnessLevel,
            int garlandsState,
            int frame,
            IPixelFrameBuffer frameBuffer)
        {
            for (int ring = 0; ring < height; ring++)
            {
                var   ratio = ring / (double)height;
                Color col   = GetMultiColorBlend(ratio, false, frame);
                if (brightnessLevel < 1)
                {
                    HSV hsv = HSV.FromRGB(col);
                    hsv.V = hsv.V * brightnessLevel;
                    col   = hsv.ToRGB();
                }

                int y      = garlandsState - ring * pixelSpacing;
                int ylimit = height - ring - 1;

                if (y < ylimit)
                {
                    y = ylimit;
                }

                switch (Type)
                {
                case 0:
                    DrawPattternType0(sparseMatrix, frameBuffer, y, ylimit, height, col);
                    break;

                case 1:
                    DrawPatternType1(sparseMatrix, frameBuffer, y, ylimit, height, col);
                    break;

                case 2:
                    DrawPatternType2(sparseMatrix, frameBuffer, y, ylimit, height, col);
                    break;

                case 3:
                    DrawPatternType3(sparseMatrix, frameBuffer, y, ylimit, height, col);
                    break;

                case 4:
                    DrawPatternType4(sparseMatrix, frameBuffer, y, ylimit, height, col);
                    break;

                default:
                    Debug.Assert(false, "Unsupported Garland Type");
                    break;
                }
            }
        }
示例#16
0
 private void CopyPixelsToTempBuf(IPixelFrameBuffer frameBuffer)
 {
     for (int x = 0; x < BufferWi; x++)
     {
         for (int y = 0; y < BufferHt; y++)
         {
             _tempbuf[x][y] = frameBuffer.GetColorAt(x, y);
         }
     }
 }
示例#17
0
 private void CopyTempBufToPixels(IPixelFrameBuffer frameBuffer)
 {
     for (int x = 0; x < BufferWi; x++)
     {
         for (int y = 0; y < BufferHt; y++)
         {
             frameBuffer.SetPixel(x, y, _tempbuf[x][y]);
         }
     }
 }
示例#18
0
 private void SetFramePixel(IPixelFrameBuffer frameBuffer, Color color, double level, int x, int y)
 {
     if (level < 1)
     {
         HSV hsv = HSV.FromRGB(color);
         hsv.V = hsv.V * level;
         color = hsv.ToRGB();
     }
     frameBuffer.SetPixel(x, y, color);
 }
示例#19
0
文件: Garlands.cs 项目: robness/Vixen
 /// <summary>
 /// Type 0 is a solid line pattern.
 /// </summary>
 void DrawPattternType0(
     IList <Tuple <int, int[]> > sparseMatrix,
     IPixelFrameBuffer frameBuffer,
     int y,
     int yLimit,
     int height,
     Color col)
 {
     DrawPatternRing(0, y, yLimit, height, sparseMatrix, frameBuffer, col, () => { return(1); });
 }
示例#20
0
        protected override void RenderEffect(int effectFrame, IPixelFrameBuffer frameBuffer)
        {
            var    intervalPos          = GetEffectTimeIntervalPosition(effectFrame);
            var    intervalPosFactor    = intervalPos * 100;
            double effectPositionAdjust = CalculateAcceleration(intervalPos, CalculateAcceleration(intervalPosFactor)) * 100.0;
            Color  c = Color.GetColorAt(intervalPos);

            double posX;
            double posY;

            if (StringOrientation == StringOrientation.Vertical)
            {
                posX = BufferWi * CalculateCenterY(intervalPosFactor) / 100.0;
                posY = BufferHt * CalculateCenterX(intervalPosFactor) / 100.0;
            }
            else
            {
                posX = BufferWi * CalculateCenterX(intervalPosFactor) / 100.0;
                posY = BufferHt * CalculateCenterY(intervalPosFactor) / 100.0;
            }

            Point  centerPoint  = new Point((int)posX, (int)posY);
            double centerRadius = CalculateRadius(effectPositionAdjust);
            double halfWidth    = CalculateWidth(effectPositionAdjust) / 2.0;
            var    radius1      = Math.Max(0.0, centerRadius - halfWidth);
            var    radius2      = centerRadius + halfWidth;

            Point currentPoint = Point.Empty;

            for (currentPoint.X = 0; currentPoint.X < BufferWi; currentPoint.X++)
            {
                for (currentPoint.Y = 0; currentPoint.Y < BufferHt; currentPoint.Y++)
                {
                    var distance = DistanceFromCenter(centerPoint, currentPoint);
                    if (ContainsPoint(distance, radius1, radius2))
                    {
                        if (BlendEdges)
                        {
                            double colorPct = 1.0 - Math.Abs(distance - centerRadius) / halfWidth;
                            if (colorPct > 0.0)
                            {
                                HSV hsv = HSV.FromRGB(c);
                                hsv.V = hsv.V * colorPct;
                                frameBuffer.SetPixel(currentPoint.X, currentPoint.Y, hsv);
                            }
                        }
                        else
                        {
                            frameBuffer.SetPixel(currentPoint.X, currentPoint.Y, c);
                        }
                    }
                }
            }
        }
示例#21
0
		/// <summary>
		/// Type 4 is the following repeating pattern:
		/// 
		///   *   *
		/// *   *   * *
		/// 0 1 2 3 4 5
		/// </summary>		
		void DrawPatternType4(
			IList<Tuple<int, int[]>> sparseMatrix,
			IPixelFrameBuffer frameBuffer,
			int y,
			int yLimit,
			int height,
			Color col)
		{
			DrawPatternRing(0, y, yLimit, height, sparseMatrix, frameBuffer, col, new int[3] { 2, 2, 1 });
			DrawPatternRing(1, y - 2, yLimit, height, sparseMatrix, frameBuffer, col, new int[2] { 2, 3 });
		}
示例#22
0
		/// <summary>
		/// Type 3 is the following repeating pattern:
		/// 
		///        * 
		/// 
		///      *   *
		/// 
		///    *       *
		///             
		///  *           *
		///  0 1 2 3 4 5 6
		/// </summary>		
		void DrawPatternType3(
			IList<Tuple<int, int[]>> sparseMatrix,
			IPixelFrameBuffer frameBuffer,
			int y,
			int yLimit,
			int height,
			Color col)
		{
			DrawPatternRing(0, y, yLimit, height, sparseMatrix, frameBuffer, col, () => { return 6; });
			DrawPatternRing(1, y - 2, yLimit, height, sparseMatrix, frameBuffer, col, new int[2] { 4, 2 });
			DrawPatternRing(2, y - 4, yLimit, height, sparseMatrix, frameBuffer, col, new int[2] { 2, 4 });
			DrawPatternRing(3, y - 6, yLimit, height, sparseMatrix, frameBuffer, col, () => { return 6; });
		}
示例#23
0
		private void DrawPatternRing(
			int startPosition,
			int y,
			int yLimit,
			int height,
			IList<Tuple<int, int[]>> sparseMatrix,
			IPixelFrameBuffer frameBuffer,
			Color col,
			int[] increments)
		{
			PatternIncrement pattern = new PatternIncrement(increments);
			DrawPatternRing(startPosition, y, yLimit, height, sparseMatrix, frameBuffer, col, pattern.GetIncrement);
		}
示例#24
0
文件: Plasma.cs 项目: starry-au/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double position    = GetEffectTimeIntervalPosition(frame) * Speed * 100;
            double plasmaSpeed = (101 - Speed) * 3;
            var    time        = (position + 1.0) / plasmaSpeed;
            double level       = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            for (int x = 0; x < BufferWi; x++)
            {
                for (int y = 0; y < BufferHt; y++)
                {
                    CalculatePixel(x, y, time, frame, level, frameBuffer);
                }
            }
        }
示例#25
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (_f == null)
            {
                return;
            }
            long   fileLength = _f.Length;
            double level      = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            int seqNumPeriods = (int)(fileLength / _seqNumChannels);

            if (frame == 0)
            {
                if (MovementType == MovementType.Iterations)
                {
                    _position = seqNumPeriods / (TimeSpan.TotalMilliseconds / FrameTime) * Iterations;               //Iterations
                }
                else
                {
                    _position = Speed;                     //Speed
                }
            }

            _speed += _position;
            int period = (int)_speed % seqNumPeriods;
            int offset = _seqNumChannels * period;

            _f.Seek(offset, SeekOrigin.Begin);
            long readcnt = _f.Read(_glediatorFrameBuffer, 0, _seqNumChannels);

            for (int j = 0; j < readcnt; j += 3)
            {
                // Loop thru all channels
                Color color = Color.FromArgb(255, _glediatorFrameBuffer[j], _glediatorFrameBuffer[j + 1], _glediatorFrameBuffer[j + 2]);
                int   x     = (j % (BufferWi * 3)) / 3;
                int   y     = (BufferHt - 1) - (j / (BufferWi * 3));
                if (level < 1)
                {
                    var hsv = HSV.FromRGB(color);
                    hsv.V *= level;
                    color  = hsv.ToRGB();
                }
                if (x < BufferWi && y < BufferHt && y >= 0)
                {
                    frameBuffer.SetPixel(x, y, color);
                }
            }
        }
示例#26
0
 protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
 {
     using (var bitmap = new Bitmap(BufferWi, BufferHt))
     {
         InitialRender(frame, bitmap);
         double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
         // copy to frameBuffer
         for (int x = 0; x < BufferWi; x++)
         {
             for (int y = 0; y < BufferHt; y++)
             {
                 CalculatePixel(x, y, bitmap, level, frameBuffer);
             }
         }
     }
 }
示例#27
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            var    intervalPos       = GetEffectTimeIntervalPosition(frame);
            var    intervalPosFactor = intervalPos * 100;
            var    speed             = CalculateSpeed(intervalPosFactor);
            double position          = intervalPosFactor * speed;
            double plasmaSpeed       = (101 - speed) * 3;
            var    time  = (position + 1.0) / plasmaSpeed;
            double level = LevelCurve.GetValue(intervalPosFactor) / 100;

            for (int x = 0; x < BufferWi; x++)
            {
                for (int y = 0; y < BufferHt; y++)
                {
                    CalculatePixel(x, y, time, frame, level, frameBuffer, intervalPosFactor);
                }
            }
        }
示例#28
0
        private void DrawCurtain(bool leftEdge, int xlimit, List <int> swagArray, IPixelFrameBuffer frameBuffer, double level, int width)
        {
            Color col;

            for (int i = 0; i < xlimit; i++)
            {
                col = Color.GetColorAt((double)i / width);
                if (level < 1)
                {
                    HSV hsv = HSV.FromRGB(col);
                    hsv.V *= level;
                    col    = hsv.ToRGB();
                }

                int x = leftEdge ? BufferWi - i - 1 : i;
                for (int y = BufferHt - 1; y >= 0; y--)
                {
                    frameBuffer.SetPixel(x, y, col);
                }
            }

            // swag
            for (int i = 0; i < swagArray.Count; i++)
            {
                int x = xlimit + i;
                col = Color.GetColorAt((double)x / width);
                if (level < 1)
                {
                    HSV hsv = HSV.FromRGB(col);
                    hsv.V *= level;
                    col    = hsv.ToRGB();
                }

                if (leftEdge)
                {
                    x = BufferWi - x - 1;
                }
                for (int y = BufferHt - 1; y > swagArray[i]; y--)
                {
                    frameBuffer.SetPixel(x, y, col);
                }
            }
        }
示例#29
0
 protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
 {
     InitFrameData(frame, out double intervalPosFactor, out double level, out double adjustedBrightness);
     InitialRender(frame, intervalPosFactor);
     if (_fp != null)
     {
         _fp.Lock();
         var bufferWi = BufferWi;
         var bufferHt = BufferHt;
         for (int x = 0; x < _imageWi; x++)
         {
             for (int y = 0; y < _imageHt; y++)
             {
                 CalculatePixel(x, y, frameBuffer, frame, level, adjustedBrightness, ref bufferHt, ref bufferWi);
             }
         }
         _fp.Unlock(false);
     }
 }
示例#30
0
        protected override void RenderEffect(int effectFrame, IPixelFrameBuffer frameBuffer)
        {
            var intervalPos       = GetEffectTimeIntervalPosition(effectFrame);
            var intervalPosFactor = intervalPos * 100;
            var bufferWi          = BufferWi;
            var bufferHt          = BufferHt;

            double level           = LevelCurve.GetValue(intervalPosFactor) / 100;
            int    thickness       = (int)Math.Round(CalculateBorderThickness(intervalPosFactor) / 2);
            int    topThickness    = (int)Math.Round(TopThicknessCurve.GetValue(intervalPosFactor) * bufferHt / 100);
            int    bottomThickness = (int)Math.Round(BottomThicknessCurve.GetValue(intervalPosFactor) * bufferHt / 100);
            int    leftThickness   = (int)Math.Round(LeftThicknessCurve.GetValue(intervalPosFactor) * bufferWi / 100);
            int    rightThickness  = (int)Math.Round(RightThicknessCurve.GetValue(intervalPosFactor) * bufferWi / 100);
            int    borderHeight    = (int)CalculateBorderHeight(intervalPosFactor) / 2;
            int    borderWidth     = (int)(CalculateBorderSize(intervalPosFactor) / 2);
            int    xOffsetAdj      = CalculateXOffset(intervalPosFactor) * (bufferWi - borderWidth) / 100;
            int    yOffsetAdj      = CalculateYOffset(intervalPosFactor) * (bufferHt - borderHeight) / 100;
            Color  color           = Color.GetColorAt(GetEffectTimeIntervalPosition(effectFrame));

            if (BorderMode == BorderMode.Simple)
            {
                thickness    = SimpleBorderWidth;
                borderWidth  = 0;
                borderHeight = 0;
            }
            else if (BorderType == BorderType.Single)
            {
                rightThickness  = thickness;
                topThickness    = thickness;
                leftThickness   = thickness;
                bottomThickness = thickness;
            }

            for (int x = 0; x < bufferWi; x++)
            {
                for (int y = 0; y < bufferHt; y++)
                {
                    CalculatePixel(x, y, frameBuffer, thickness, topThickness,
                                   bottomThickness, leftThickness, rightThickness, level, borderWidth, borderHeight, color, xOffsetAdj, yOffsetAdj, ref bufferHt, ref bufferWi);
                }
            }
        }
示例#31
0
文件: PinWheel.cs 项目: jaredb7/vixen
        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);
                }
            }
        }
示例#32
0
文件: Life.cs 项目: jaredb7/vixen
 private void CopyPixelsToTempBuf(IPixelFrameBuffer frameBuffer)
 {
     for (int x = 0; x < BufferWi; x++)
     {
         for (int y = 0; y < BufferHt; y++)
         {
             _tempbuf[x][y] = frameBuffer.GetColorAt(x,y);
         }
     }
 }
示例#33
0
        protected override void RenderEffect(int effectFrame, IPixelFrameBuffer frameBuffer)
        {
            double position = GetEffectTimeIntervalPosition(effectFrame);
            double effectPositionAdjust = CalculateAcceleration(position, Acceleration);
            Color c = Color.GetColorAt(position);

            double posX = BufferWi * CenterX / 100.0;
            double posY = BufferHt * CenterY / 100.0;
            Point centerPoint = new Point((int)posX, (int)posY);
            double centerRadius = StartRadius + (EndRadius - StartRadius) * effectPositionAdjust;
            double halfWidth = (StartWidth + (EndWidth - StartWidth) * effectPositionAdjust) / 2.0;
            var radius1 = Math.Max(0.0, centerRadius - halfWidth);
            var radius2 = centerRadius + halfWidth;

            Point currentPoint = Point.Empty;

            for (currentPoint.X = 0; currentPoint.X < BufferWi; currentPoint.X++)
            {
                for (currentPoint.Y = 0; currentPoint.Y < BufferHt; currentPoint.Y++)
                {
                    var distance = DistanceFromCenter(centerPoint, currentPoint);
                    if (ContainsPoint(distance, radius1, radius2))
                    {
                        if (BlendEdges)
                        {
                            double colorPct = 1.0 - Math.Abs(distance - centerRadius) / halfWidth;
                            if (colorPct > 0.0)
                            {
                                HSV hsv = HSV.FromRGB(c);
                                hsv.V = hsv.V * colorPct;
                                frameBuffer.SetPixel(currentPoint.X, currentPoint.Y, hsv);
                            }
                        }
                        else
                        {
                            frameBuffer.SetPixel(currentPoint.X, currentPoint.Y, c);
                        }
                    }
                }
            }
        }
示例#34
0
文件: Life.cs 项目: jaredb7/vixen
 private void CopyTempBufToPixels(IPixelFrameBuffer frameBuffer)
 {
     for (int x = 0; x < BufferWi; x++) {
         for (int y = 0; y < BufferHt; y++) {
             frameBuffer.SetPixel(x, y, _tempbuf[x][y]);
         }
     }
 }
示例#35
0
文件: Meteors.cs 项目: jaredb7/vixen
        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++;
                }
            }
        }
示例#36
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (_f == null) return;
            long fileLength = _f.Length;

            int seqNumPeriods = (int) (fileLength/ _seqNumChannels);

            if (frame == 0)
            {
                if (MovementType == MovementType.Iterations)
                    _position = seqNumPeriods/(TimeSpan.TotalMilliseconds/FrameTime)*Iterations; //Iterations
                else
                    _position = Speed; //Speed
            }

            _speed += _position;
            int period = (int)_speed % seqNumPeriods;
            int offset = _seqNumChannels * period;
            _f.Seek(offset, SeekOrigin.Begin);
            long readcnt = _f.Read(_glediatorFrameBuffer, 0, _seqNumChannels);

            for (int j = 0; j < readcnt; j += 3)
            {
                // Loop thru all channels
                Color color = Color.FromArgb(255, _glediatorFrameBuffer[j], _glediatorFrameBuffer[j + 1], _glediatorFrameBuffer[j + 2]);
                int x = (j%(BufferWi*3))/3;
                int y = (BufferHt - 1) - (j/(BufferWi*3));
                var hsv = HSV.FromRGB(color);
                hsv.V = hsv.V*LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame)*100)/100;
                if (x < BufferWi && y < BufferHt && y >= 0)
                {
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }
        }
示例#37
0
 protected abstract void RenderEffect(int frameNum, IPixelFrameBuffer frameBuffer);
示例#38
0
文件: Video.cs 项目: jaredb7/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double position = (GetEffectTimeIntervalPosition(frame) * Speed) % 1;
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            // If we don't have any pictures, do nothing!
            if (_moviePicturesFileList == null || !_moviePicturesFileList.Any())
                return;

            int pictureCount = _moviePicturesFileList.Count;

            if (PlayBackSpeed > 0)
            {
                _currentMovieImageNum += ((PlayBackSpeed * .01) + 1);
            }
            else if (PlayBackSpeed < 0)
            {
                _currentMovieImageNum += (100 + PlayBackSpeed) * .01;
            }
            else
            {
                _currentMovieImageNum ++;
            }

            int currentImage = Convert.ToInt32(_currentMovieImageNum);
            if (currentImage >= pictureCount || currentImage < 0)
                _currentMovieImageNum = currentImage = 0;

            // copy image to buffer
            Bitmap resizeImage = new Bitmap(Image.FromFile(_moviePicturesFileList[currentImage]));
            FastPixel.FastPixel currentMovieImage = new FastPixel.FastPixel(new Bitmap(resizeImage));

            int imgwidth = currentMovieImage.Width;
            int imght = currentMovieImage.Height;
            int yoffset = (BufferHt + imght) / 2;
            int xoffset = (imgwidth - BufferWi) / 2;
            int xOffsetAdj = XOffset * BufferWi / 100;
            int yOffsetAdj = YOffset * BufferHt / 100;

            switch (Type)
            {
                case EffectType.RenderPicturePeekaboo0:
                case EffectType.RenderPicturePeekaboo180:
                    //Peek a boo
                    yoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                    if (yoffset > 10)
                    {
                        yoffset = -yoffset + 10; //reverse direction
                    }
                    else if (yoffset >= -1)
                    {
                        yoffset = -1; //pause in middle
                    }

                    break;
                case EffectType.RenderPictureWiggle:
                    if (position >= 0.5)
                    {
                        xoffset += (int)(BufferWi * ((1.0 - position) * 2.0 - 0.5));
                    }
                    else
                    {
                        xoffset += (int)(BufferWi * (position * 2.0 - 0.5));
                    }
                    break;
                case EffectType.RenderPicturePeekaboo90: //peekaboo 90
                case EffectType.RenderPicturePeekaboo270: //peekaboo 270
                    if (Orientation == StringOrientation.Vertical)
                    {
                        yoffset = (imght - BufferWi) / 2; //adjust offsets for other axis
                        xoffset = -(BufferHt) + (int)((BufferHt + 5) * position * 2);
                    }
                    else
                    {
                        yoffset = (imgwidth - BufferHt) / 2; //adjust offsets for other axis
                        xoffset = -(BufferWi) + (int)((BufferWi + 5) * position * 2);
                    }
                    if (xoffset > 10)
                    {
                        xoffset = -xoffset + 10; //reverse direction
                    }
                    else if (xoffset >= -1)
                    {
                        xoffset = -1; //pause in middle
                    }

                    break;
            }

            currentMovieImage.Lock();
            Color fpColor = new Color();
            for (int x = 0; x < imgwidth; x++)
            {
                for (int y = 0; y < imght; y++)
                {
                    fpColor = currentMovieImage.GetPixel(x, y);
                    if (fpColor != Color.Transparent && fpColor != Color.Black)
                    {
                        var hsv = HSV.FromRGB(fpColor);
                        double tempV = hsv.V * level * ((double)(IncreaseBrightness)/10);
                        if (tempV > 1)
                            tempV = 1;
                        hsv.V = tempV;
                        int leftX, rightX, upY, downY;
                        switch (_data.EffectType)
                        {
                            case EffectType.RenderPictureLeft:
                                // left
                                leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));

                                frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureRight:
                                // right
                                rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                                frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUp:
                                // up
                                upY = (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureDown:
                                // down
                                downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUpleft:
                                // up-left
                                leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));
                                upY = (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(leftX + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureDownleft:
                                // down-left
                                leftX = x + (BufferWi - (int)(position * (imgwidth + BufferWi)));
                                downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;

                                frameBuffer.SetPixel(leftX + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUpright:
                                // up-right
                                upY = (int)((imght + BufferHt) * position) - y;
                                rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                                frameBuffer.SetPixel(rightX + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureDownright:
                                // down-right
                                downY = (BufferHt + imght - 1) - (int)((imght + BufferHt) * position) - y;
                                rightX = x + -imgwidth + (int)(position * (imgwidth + BufferWi));

                                frameBuffer.SetPixel(rightX + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo0:
                                // Peek a boo 0
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureWiggle:
                                // Wiggle
                                frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo90:
                                // Peekaboo90
                                frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, x - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo180:
                                // Peekaboo180
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo270:
                                // Peekaboo270
                                frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - x + yOffsetAdj, hsv);
                                break;
                            default:
                                // no movement - centered
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                        }
                    }
                }
            }
            currentMovieImage.Unlock(false);
            currentMovieImage.Dispose();
            resizeImage.Dispose();
        }
示例#39
0
文件: Text.cs 项目: jaredb7/vixen
        private void CalculatePixel(int x, int y, Bitmap bitmap, double level, IPixelFrameBuffer frameBuffer)
        {
            int yCoord = y;
            int xCoord = x;
            if (TargetPositioning == TargetPositioningType.Locations)
            {
                //Flip me over so and offset my coordinates I can act like the string version
                y = Math.Abs((BufferHtOffset - y) + (BufferHt - 1 + BufferHtOffset));
                y = y - BufferHtOffset;
                x = x - BufferWiOffset;
            }
            Color color = bitmap.GetPixel(x, BufferHt - y - 1);

            if (!EmptyColor.Equals(color))
            {
                var hsv = HSV.FromRGB(color);
                hsv.V = hsv.V*level;

                frameBuffer.SetPixel(xCoord, yCoord, hsv);
            }
            else if (TargetPositioning == TargetPositioningType.Locations)
            {
                //Set me to my base color or transparent
                frameBuffer.SetPixel(xCoord, yCoord, UseBaseColor ? BaseColor : Color.Transparent);
            }
        }
示例#40
0
文件: Text.cs 项目: jaredb7/vixen
 protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
 {
     using (var bitmap = new Bitmap(BufferWi, BufferHt))
     {
         InitialRender(frame, bitmap);
         double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
         // copy to frameBuffer
         for (int x = 0; x < BufferWi; x++)
         {
             for (int y = 0; y < BufferHt; y++)
             {
                 CalculatePixel(x, y, bitmap, level, frameBuffer);
             }
         }
     }
 }
示例#41
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
            int width, height;
            double totalFrames = (int)(TimeSpan.TotalMilliseconds / FrameTime) -1;

            int pixelSpacing = Spacing * BufferHt / 100 + 3;
            if (Direction == GarlandsDirection.Up || Direction == GarlandsDirection.Down)
            {
                width = BufferWi;
                height = BufferHt;
            }
            else
            {
                width = BufferHt;
                height = BufferWi;
            }
            int limit = height * pixelSpacing * 4;
            int garlandsState;
            if (MovementType == MovementType.Iterations)
            {
                garlandsState = (int) (limit - ((_frames)*(limit/totalFrames*Iterations)))/4; //Iterations
                if (garlandsState <= 0)
                    _frames = 0;
            }
            else
            {
                _speed += Speed;
                garlandsState = (limit - _speed % limit) / 4; //Speed
            }
            _frames++;

            for (int ring = 0; ring < height; ring++)
            {
                var ratio = ring / (double)height;
                var color = GetMultiColorBlend(ratio, false, frame);
                var hsv = HSV.FromRGB(color);
                hsv.V = hsv.V*level;

                var y = garlandsState - ring * pixelSpacing;
                var ylimit = height - ring - 1;
                for (int x = 0; x < width; x++)
                {
                    var yadj = y;
                    switch (Type)
                    {
                        case 1:
                            switch (x % 5)
                            {
                                case 2:
                                    yadj -= 2;
                                    break;
                                case 1:
                                case 3:
                                    yadj -= 1;
                                    break;
                            }
                            break;
                        case 2:
                            switch (x % 5)
                            {
                                case 2:
                                    yadj -= 4;
                                    break;
                                case 1:
                                case 3:
                                    yadj -= 2;
                                    break;
                            }
                            break;
                        case 3:
                            switch (x % 6)
                            {
                                case 3:
                                    yadj -= 6;
                                    break;
                                case 2:
                                case 4:
                                    yadj -= 4;
                                    break;
                                case 1:
                                case 5:
                                    yadj -= 2;
                                    break;
                            }
                            break;
                        case 4:
                            switch (x % 5)
                            {
                                case 1:
                                case 3:
                                    yadj -= 2;
                                    break;
                            }
                            break;
                    }
                    switch (Direction)
                    {
                        case GarlandsDirection.Down:
                            if (yadj < ylimit) yadj = ylimit;
                            if (yadj < BufferHt) frameBuffer.SetPixel(x, BufferHt - yadj, hsv);
                        break;
                        case GarlandsDirection.Up:
                            if (yadj < ylimit) yadj = ylimit;
                            if (yadj < BufferHt) frameBuffer.SetPixel(x, yadj, hsv);
                        break;
                        case GarlandsDirection.Left:
                            if (yadj < ylimit) yadj = ylimit;
                            if (yadj < BufferWi) frameBuffer.SetPixel(BufferWi - yadj, x, hsv);
                        break;
                        case GarlandsDirection.Right:
                            if (yadj < ylimit) yadj = ylimit;
                            if (yadj < BufferWi) frameBuffer.SetPixel(yadj, x, hsv);
                        break;
                    }
                }
            }
        }
示例#42
0
文件: Spiral.cs 项目: jaredb7/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            int colorcnt = Colors.Count();
            int spiralCount = colorcnt * Repeat;
            int deltaStrands = BufferWi / spiralCount;
            int spiralThickness = (deltaStrands * Thickness / 100)+1;
            int spiralGap = deltaStrands - spiralThickness;
            int thicknessState = 0;
            int spiralState = 0;
            double position = (GetEffectTimeIntervalPosition(frame) * Speed)%1;

            switch (Direction)
            {
                case SpiralDirection.Forward:
                    spiralState = (int)(position*BufferWi*10);
                    break;
                case SpiralDirection.Backwards:
                    spiralState = (int)(position * BufferWi * -10);
                    break;
            }

            if (Grow && Shrink)
            {
                thicknessState = (int)(position <= 0.5 ? spiralGap * (position * 2) : spiralGap * ((1 - position) * 2));
            }
            else if (Grow)
            {
                thicknessState = (int)(spiralGap * position);
            }
            else if (Shrink)
            {
                thicknessState = (int)(spiralGap * (1.0 - position));
            }

            spiralThickness += thicknessState;
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            for (int ns = 0; ns < spiralCount; ns++)
            {
                var strandBase = ns * deltaStrands;
                int colorIdx = ns % colorcnt;

                int thick;
                for (thick = 0; thick < spiralThickness; thick++)
                {
                    var strand = (strandBase + thick) % BufferWi;
                    int y;
                    for (y = 0; y < BufferHt; y++)
                    {
                        Color color;
                        var x = (strand + (spiralState / 10) + (y * Rotation / BufferHt)) % BufferWi;
                        if (x < 0) x += BufferWi;
                        if (Blend)
                        {
                            color = Colors[colorIdx].GetColorAt((double)(BufferHt - y - 1) / BufferHt);
                        }
                        else
                        {
                            color = Colors[colorIdx].GetColorAt((double) thick/spiralThickness);
                        }
                        if (Show3D)
                        {
                            var hsv = HSV.FromRGB(color);

                            if (Rotation < 0)
                            {
                                hsv.V = (float)((double)(thick + 1) / spiralThickness);
                            }
                            else
                            {
                                hsv.V = (float)((double)(spiralThickness - thick) / spiralThickness);
                            }
                            hsv.V = hsv.V * level;
                            frameBuffer.SetPixel(x, y, hsv);
                        }
                        else
                        {
                            var hsv = HSV.FromRGB(color);
                            hsv.V = hsv.V * level;
                            frameBuffer.SetPixel(x, y, hsv);
                        }
                    }
                }
            }
        }
示例#43
0
文件: Text.cs 项目: eberletj/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            using (var bitmap = new Bitmap(BufferWi, BufferHt))
            {
                InitialRender(frame, bitmap);

                // copy to frameBuffer
                for (int x = 0; x < BufferWi; x++)
                {
                    for (int y = 0; y < BufferHt; y++)
                    {
                        CalculatePixel(x, y, bitmap, frame, frameBuffer);
                    }
                }
            }
        }
示例#44
0
文件: Picture.cs 项目: jaredb7/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (_image == null)
            {
                Logging.Error("Image object is null");
                return;
            }
            var dir = 360 - Direction;
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
            int speedFactor = 4;
            int state = MovementRate * frame;
            if (Type != EffectType.RenderPictureTiles && Type != EffectType.RenderPictureNone)
            {
                _position = ((GetEffectTimeIntervalPosition(frame) * Speed) % 1);
            }
            else if (frame == 0)
            {
                _position = ((GetEffectTimeIntervalPosition(frame + 1) * Speed) % 1);
            }

            CalculateImageNumberByPosition((GetEffectTimeIntervalPosition(frame)*GifSpeed)%1);
            _image.SelectActiveFrame(_dimension, (int) _currentGifImageNum);
            _scaledImage = ScaleToGrid
                ? ScalePictureImage(_image, BufferWi, BufferHt)
                : ScaleImage(_image, (double) ScalePercent/100);

            if (ColorEffect == ColorEffect.GreyScale)
            {
                _scaledImage = (Bitmap) ConvertToGrayScale(_scaledImage);
            }
            _fp = new FastPixel.FastPixel(_scaledImage);

            if (_fp != null)
            {
                int imageWidth = _fp.Width;
                int imageHeight = _fp.Height;
                double deltaX = 0;
                double deltaY = 0;
                double angleOffset;

                if (dir > 45 && dir <= 90)
                    angleOffset = -(dir - 90);
                else if (dir > 90 && dir <= 135)
                    angleOffset = dir - 90;
                else if (dir > 135 && dir <= 180)
                    angleOffset = -(dir - 180);
                else if (dir > 180 && dir <= 225)
                    angleOffset = dir - 180;
                else if (dir > 225 && dir <= 270)
                    angleOffset = -(dir - 270);
                else if (dir > 270 && dir <= 315)
                    angleOffset = dir - 270;
                else if (dir > 315 && dir <= 360)
                    angleOffset = -(dir - 360);
                else
                    angleOffset = dir;

                double imageSpeed = _position*(imageWidth/(Math.Cos((Math.PI/180)*angleOffset)));

                //Moving left and right
                if (dir > 0 && dir <= 90)
                {
                    deltaX = ((double) dir/90)*(imageSpeed);
                }
                else if (dir > 90 && dir <= 180)
                {
                    deltaX = ((double) Math.Abs(dir - 180)/90)*(imageSpeed);
                }
                else if (dir > 180 && dir <= 270)
                {
                    deltaX = -1*(((double) Math.Abs(dir - 180)/90)*(imageSpeed));
                }
                else if (dir > 270 && dir <= 360)
                {
                    deltaX = -1*(((double) Math.Abs(dir - 360)/90)*(imageSpeed));
                }

                //Moving up and down
                if (dir >= 0 && dir <= 90)
                {
                    deltaY = (((double) Math.Abs(dir - 90)/90))*(imageSpeed);
                }
                else if (dir > 90 && dir <= 180)
                {
                    deltaY = -1*(((double) Math.Abs(dir - 90)/90)*(imageSpeed));
                }
                else if (dir > 180 && dir <= 270)
                {
                    deltaY = -1*(((double) Math.Abs(dir - 270)/90)*(imageSpeed));
                }
                else if (dir > 270 && dir <= 360)
                {
                    deltaY = ((double) Math.Abs(270 - dir)/90)*(imageSpeed);
                }

                _movementX += deltaX;
                _movementY += deltaY;

                _fp.Lock();
                Color fpColor = new Color();

                int yoffset = (BufferHt + imageHeight)/2;
                int xoffset = (imageWidth - BufferWi)/2;
                int xOffsetAdj = XOffset*BufferWi/100;
                int yOffsetAdj = YOffset*BufferHt/100;
                int imageHt = imageHeight;
                int imageWi = imageWidth;

                switch (Type)
                {
                    case EffectType.RenderPicturePeekaboo0:
                    case EffectType.RenderPicturePeekaboo180:
                        //Peek a boo
                        yoffset = -(BufferHt) + (int) ((BufferHt + 5)*_position*2);
                        if (yoffset > 10)
                        {
                            yoffset = -yoffset + 10; //reverse direction
                        }
                        else if (yoffset >= -1)
                        {
                            yoffset = -1; //pause in middle
                        }
                        break;
                    case EffectType.RenderPictureWiggle:
                        if (_position >= 0.5)
                        {
                            xoffset += (int) (BufferWi*((1.0 - _position)*2.0 - 0.5));
                        }
                        else
                        {
                            xoffset += (int) (BufferWi*(_position*2.0 - 0.5));
                        }
                        break;
                    case EffectType.RenderPicturePeekaboo90: //peekaboo 90
                    case EffectType.RenderPicturePeekaboo270: //peekaboo 270
                        if (Orientation == StringOrientation.Vertical)
                        {
                            yoffset = (imageHt - BufferWi)/2; //adjust offsets for other axis
                        }
                        else
                        {
                            yoffset = (imageWi - BufferHt)/2; //adjust offsets for other axis
                        }

                        if (Orientation == StringOrientation.Vertical)
                        {
                            xoffset = -(BufferHt) + (int) ((BufferHt + 5)*_position*2);
                        }
                        else
                        {
                            xoffset = -(BufferWi) + (int) ((BufferWi + 5)*_position*2);
                        }
                        if (xoffset > 10)
                        {
                            xoffset = -xoffset + 10; //reverse direction
                        }
                        else if (xoffset >= -1)
                        {
                            xoffset = -1; //pause in middle
                        }

                        break;
                    case EffectType.RenderPictureTiles:
                        imageHt = BufferHt;
                        imageWi = BufferWi;
                        break;

                }
                for (int x = 0; x < imageWi; x++)
                {
                    for (int y = 0; y < imageHt; y++)
                    {
                        if (Type != EffectType.RenderPictureTiles) // change this so only when tiles are disabled
                        {
                            fpColor = _fp.GetPixel(x, y);
                        }

                        var hsv = HSV.FromRGB(fpColor);
                        double tempV = hsv.V*level*((double) (IncreaseBrightness)/10);
                        if (tempV > 1)
                            tempV = 1;
                        hsv.V = tempV;

                        switch (Type)
                        {
                            case EffectType.RenderPicturePeekaboo0:

                                if (fpColor != Color.Transparent)
                                {
                                    //Peek a boo
                                    hsv = CustomColor(hsv, frame, level, fpColor);
                                    frameBuffer.SetPixel(x - xoffset + xOffsetAdj, BufferHt + yoffset - y + yOffsetAdj, hsv);
                                }
                                break;
                            case EffectType.RenderPictureWiggle:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x + xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo90:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(BufferWi + xoffset - y + xOffsetAdj, x - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo180:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, y - yoffset + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPicturePeekaboo270:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(y - xoffset + xOffsetAdj, BufferHt + yoffset - x + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureLeft:
                                // left
                                int leftX = x + (BufferWi - (int) (_position*(imageWi + BufferWi)));
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(leftX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureRight:
                                // right
                                int rightX = x + -imageWi + (int) (_position*(imageWi + BufferWi));
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(rightX + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureUp:
                                // up
                                int upY = (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, upY + yOffsetAdj, hsv);
                                break;

                            case EffectType.RenderPictureUpleft:
                                int upLeftY = (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + BufferWi - (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor) + xOffsetAdj,
                                    upLeftY + yOffsetAdj, hsv);
                                break; // up-left
                            case EffectType.RenderPictureDownleft:
                                int downLeftY = BufferHt + imageHt - (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + BufferWi - (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor) + xOffsetAdj,
                                    downLeftY + yOffsetAdj, hsv);
                                break; // down-left
                            case EffectType.RenderPictureUpright:
                                int upRightY = (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor - imageWi) + xOffsetAdj,
                                    upRightY + yOffsetAdj, hsv);
                                break; // up-right
                            case EffectType.RenderPictureDownright:
                                int downRightY = BufferHt + imageHt - (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(
                                    Convert.ToInt32(x + (state % ((imageWi + BufferWi) * speedFactor)) / speedFactor - imageWi) + xOffsetAdj,
                                    downRightY + yOffsetAdj, hsv);
                                break; // down-right
                            case EffectType.RenderPictureDown:
                                // down
                                int downY = (BufferHt + imageHt - 1) - (int) ((imageHt + BufferHt)*_position) - y;
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, downY + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureNone:
                                hsv = CustomColor(hsv, frame, level, fpColor);
                                frameBuffer.SetPixel(x - xoffset + xOffsetAdj, yoffset - y + yOffsetAdj, hsv);
                                break;
                            case EffectType.RenderPictureTiles:
                                int colorX = x + Convert.ToInt32(_movementX) - (XOffset*BufferWi/100);
                                int colorY = y + Convert.ToInt32(_movementY) + (YOffset*BufferHt/100);

                                if (colorX >= 0)
                                {
                                    colorX = colorX%imageWidth;
                                }
                                else if (colorX < 0)
                                {
                                    colorX = Convert.ToInt32(colorX%imageWidth) + imageWidth - 1;
                                }

                                if (colorY >= 0)
                                {
                                    colorY = Convert.ToInt32((colorY%imageHeight));
                                }
                                else if (colorY < 0)
                                {
                                    colorY = Convert.ToInt32(colorY%imageHeight) + imageHeight - 1;
                                }
                                if (colorX <= _fp.Width && colorY <= _fp.Height)
                                {
                                    fpColor = _fp.GetPixel(colorX, colorY);

                                    hsv = HSV.FromRGB(fpColor);
                                    hsv = CustomColor(hsv, frame, level, fpColor);
                                    frameBuffer.SetPixel(x, BufferHt - y - 1, hsv);
                                }
                                break;
                        }
                    }
                }
                _fp.Unlock(false);
                _fp.Dispose();
                _scaledImage.Dispose();
            }
        }
示例#45
0
文件: Bars.cs 项目: jaredb7/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            var buffer = frameBuffer as PixelLocationFrameBuffer;
            if (buffer != null)
            {
                RenderEffectByLocation(frame, buffer);
            }

            int x, y, n, colorIdx;
            int colorcnt = Colors.Count();
            int barCount = Repeat * colorcnt;
            double position = (GetEffectTimeIntervalPosition(frame) * Speed) % 1;
            if (barCount < 1) barCount = 1;
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            if (Direction < BarDirection.Left || Direction == BarDirection.AlternateUp || Direction == BarDirection.AlternateDown)
            {
                int barHt = BufferHt / barCount+1;
                if (barHt < 1) barHt = 1;
                int halfHt = BufferHt / 2;
                int blockHt = colorcnt * barHt;
                if (blockHt < 1) blockHt = 1;
                int fOffset = (int) (position*blockHt*Repeat);// : Speed * frame / 4 % blockHt);
                if(Direction == BarDirection.AlternateUp || Direction == BarDirection.AlternateDown)
                {
                    fOffset = (int)(Math.Floor(position*barCount)*barHt);
                }
                int indexAdjust = 1;

                for (y = 0; y < BufferHt; y++)
                {
                    n = y + fOffset;
                    colorIdx = ((n + indexAdjust) % blockHt) / barHt;
                    //we need the integer division here to make things work
                    double colorPosition = ((double)(n + indexAdjust) / barHt) - ((n + indexAdjust) / barHt);
                    Color c = Colors[colorIdx].GetColorAt(colorPosition);
                    var hsv = HSV.FromRGB(c);
                    if (Highlight && (n + indexAdjust) % barHt == 0) hsv.S = 0.0f;
                    if (Show3D) hsv.V *= (float)(barHt - (n + indexAdjust) % barHt - 1) / barHt;

                    hsv.V = hsv.V*level;

                    switch (Direction)
                    {
                        case BarDirection.Down:
                        case BarDirection.AlternateDown:
                            // down
                            for (x = 0; x < BufferWi; x++)
                            {
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            break;
                        case BarDirection.Expand:
                            // expand
                            if (y <= halfHt)
                            {
                                for (x = 0; x < BufferWi; x++)
                                {
                                    frameBuffer.SetPixel(x, y, hsv);
                                    frameBuffer.SetPixel(x, BufferHt - y - 1, hsv);
                                }
                            }
                            break;
                        case BarDirection.Compress:
                            // compress
                            if (y >= halfHt)
                            {
                                for (x = 0; x < BufferWi; x++)
                                {
                                    frameBuffer.SetPixel(x, y, hsv);
                                    frameBuffer.SetPixel(x, BufferHt - y - 1, hsv);
                                }
                            }
                            break;
                        default:
                            // up & AlternateUp
                            for (x = 0; x < BufferWi; x++)
                            {
                                frameBuffer.SetPixel(x, BufferHt - y - 1, hsv);
                            }
                            break;
                    }
                }
            }
            else
            {
                int barWi = BufferWi / barCount+1;
                if (barWi < 1) barWi = 1;
                int halfWi = BufferWi / 2;
                int blockWi = colorcnt * barWi;
                if (blockWi < 1) blockWi = 1;
                int fOffset = (int)(position * blockWi * Repeat);
                if (Direction > BarDirection.AlternateDown)
                {
                    fOffset = (int)(Math.Floor(position * barCount) * barWi);
                }

                for (x = 0; x < BufferWi; x++)
                {
                    n = x + fOffset;
                    colorIdx = ((n + 1) % blockWi) / barWi;
                    //we need the integer division here to make things work
                    double colorPosition = ((double)(n + 1) / barWi) - ((n + 1) / barWi);
                    Color c = Colors[colorIdx].GetColorAt( colorPosition );
                    var hsv = HSV.FromRGB(c);
                    if (Highlight && n % barWi == 0) hsv.S = 0.0f;
                    if (Show3D) hsv.V *= (float)(barWi - n % barWi - 1) / barWi;
                    hsv.V = hsv.V * level;
                    switch (Direction)
                    {
                        case BarDirection.Right:
                        case BarDirection.AlternateRight:
                            // right
                            for (y = 0; y < BufferHt; y++)
                            {
                                frameBuffer.SetPixel(BufferWi - x - 1, y, hsv);
                            }
                            break;
                        case BarDirection.HExpand:
                            // H-expand
                            if (x <= halfWi)
                            {
                                for (y = 0; y < BufferHt; y++)
                                {
                                    frameBuffer.SetPixel(x, y, hsv);
                                    frameBuffer.SetPixel(BufferWi - x - 1, y, hsv);
                                }
                            }
                            break;
                        case BarDirection.HCompress:
                            // H-compress
                            if (x >= halfWi)
                            {
                                for (y = 0; y < BufferHt; y++)
                                {
                                    frameBuffer.SetPixel(x, y, hsv);
                                    frameBuffer.SetPixel(BufferWi - x - 1, y, hsv);
                                }
                            }
                            break;
                        default:
                            // left & AlternateLeft
                            for (y = 0; y < BufferHt; y++)
                            {
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            break;
                    }
                }
            }
        }
示例#46
0
文件: Life.cs 项目: jaredb7/vixen
        // use tempbuf for calculations
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
            int i, x, y;
            Color color;
            int state = frame * Speed;
            int count = BufferWi * BufferHt * CellsToStart / 200 + 1;
            if (frame == 0)
            {
                ClearTempBuf();
                for (i = 0; i < count; i++)
                {
                    x = rand() % BufferWi;
                    y = rand() % BufferHt;
                    color = GetMultiColorBlend(rand01(), frame);
                    HSV hsv = HSV.FromRGB(color);
                    hsv.V = hsv.V * level;
                    color = hsv.ToRGB();
                    SetTempPixel(x, y, color);
                }
            }
            long tempState = (state % 400) / 20;
            if (tempState == _lastLifeState)
            {
                //Pixels=tempbuf;
                CopyTempBufToPixels(frameBuffer);
                return;
            }
            _lastLifeState = tempState;

            for (x = 0; x < BufferWi; x++)
            {
                for (y = 0; y < BufferHt; y++)
                {
                    color = GetTempPixel(x, y);
                    //isLive=(color.GetRGB() != 0);
                    bool isLive = (color != Color.Black && color != Color.Transparent);
                    int cnt = Life_CountNeighbors(x, y);
                    switch (Type)
                    {
                        case 0:
                            // B3/S23
                            /*
                        Any live cell with fewer than two live neighbours dies, as if caused by under-population.
                        Any live cell with two or three live neighbours lives on to the next generation.
                        Any live cell with more than three live neighbours dies, as if by overcrowding.
                        Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
                        */
                            if (isLive && cnt >= 2 && cnt <= 3)
                            {
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            else if (!isLive && cnt == 3)
                            {
                                color = GetMultiColorBlend(rand01(), frame);
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            break;
                        case 1:
                            // B35/S236
                            if (isLive && (cnt == 2 || cnt == 3 || cnt == 6))
                            {
                                color = GetMultiColorBlend(rand01(), frame);
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            else if (!isLive && (cnt == 3 || cnt == 5))
                            {
                                color = GetMultiColorBlend(rand01(), frame);
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            break;
                        case 2:
                            // B357/S1358
                            if (isLive && (cnt == 1 || cnt == 3 || cnt == 5 || cnt == 8))
                            {
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            else if (!isLive && (cnt == 3 || cnt == 5 || cnt == 7))
                            {
                                color = GetMultiColorBlend(rand01(), frame);
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            break;
                        case 3:
                            // B378/S235678
                            if (isLive && (cnt == 2 || cnt == 3 || cnt >= 5))
                            {
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            else if (!isLive && (cnt == 3 || cnt == 7 || cnt == 8))
                            {
                                color = GetMultiColorBlend(rand01(), frame);
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            break;
                        case 4:
                            // B25678/S5678
                            if (isLive && (cnt >= 5))
                            {
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            else if (!isLive && (cnt == 2 || cnt >= 5))
                            {
                                color = GetMultiColorBlend(rand01(), frame);
                                HSV hsv = HSV.FromRGB(color);
                                hsv.V = hsv.V * level;
                                frameBuffer.SetPixel(x, y, hsv);
                            }
                            break;
                    }
                }
            }
            // copy new life state to tempbuf
            CopyPixelsToTempBuf(frameBuffer);
        }
示例#47
0
文件: PinWheel.cs 项目: jaredb7/vixen
        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);
            }
        }
示例#48
0
文件: Curtain.cs 项目: jaredb7/vixen
        private void DrawCurtain(bool leftEdge, int xlimit, List<int> swagArray, IPixelFrameBuffer frameBuffer, double level, int width)
        {
            int i, x, y;
            for (i = 0; i < xlimit; i++)
            {
                HSV hsv = HSV.FromRGB(Color.GetColorAt((double)i / width));
                x = leftEdge ? BufferWi - i - 1 : i;
                for (y = BufferHt - 1; y >= 0; y--)
                {
                    hsv.V = hsv.V*level;
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }

            // swag
            for (i = 0; i < swagArray.Count; i++)
            {
                x = xlimit + i;
                HSV hsv = HSV.FromRGB(Color.GetColorAt((double)x / width));
                if (leftEdge) x = BufferWi - x - 1;
                for (y = BufferHt - 1; y > swagArray[i]; y--)
                {
                    hsv.V = hsv.V*level;
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }
        }
示例#49
0
文件: Curtain.cs 项目: jaredb7/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            var swagArray = new List<int>();
            int curtainDir, xlimit, middle, ylimit;
            int swaglen = BufferHt > 1 ? Swag*BufferWi/40 : 0;
            double position = (GetEffectTimeIntervalPosition(frame)*Speed)%1;
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            if (swaglen > 0)
            {
                double a = (double) (BufferHt - 1)/(swaglen*swaglen);
                for (int x = 0; x < swaglen; x++)
                {
                    swagArray.Add((int) (a*x*x));
                }
            }
            if (Direction < CurtainDirection.CurtainOpenClose)
            {
                xlimit = (int) (position*BufferWi);
                ylimit = (int) (position*BufferHt);
            }
            else
            {
                xlimit = (int) (position <= .5 ? position*2*BufferWi : (position - .5)*2*BufferWi);
                ylimit = (int) (position <= .5 ? position*2*BufferHt : (position - .5)*2*BufferHt);
            }
            if (Direction < CurtainDirection.CurtainOpenClose)
            {
                curtainDir = (int)Direction % 2;
            }
            else if (xlimit < _lastCurtainLimit)
            {
                curtainDir = 1 - _lastCurtainDir;
            }
            else
            {
                curtainDir = _lastCurtainDir;
            }
            _lastCurtainDir = curtainDir;
            _lastCurtainLimit = xlimit;
            if (curtainDir == 0)
            {
                xlimit = BufferWi - xlimit - 1;
                ylimit = BufferHt - ylimit - 1;
            }
            switch (Edge)
            {
                case CurtainEdge.Left:
                    // left
                    DrawCurtain(true, xlimit, swagArray, frameBuffer, level, (BufferWi- 1));
                    break;
                case CurtainEdge.Center:
                    // center
                    middle = (xlimit + 1)/2;
                    DrawCurtain(true, middle, swagArray, frameBuffer, level, (BufferWi / 2 - 1));
                    DrawCurtain(false, middle, swagArray, frameBuffer, level, (BufferWi / 2 - 1));
                    break;
                case CurtainEdge.Right:
                    // right
                    DrawCurtain(false, xlimit, swagArray, frameBuffer, level, (BufferWi - 1));
                    break;
                case CurtainEdge.Bottom:

                    // bottom
                    DrawCurtainVertical(true, ylimit, swagArray, frameBuffer, level, (BufferHt - 1));
                    break;
                case CurtainEdge.Middle:
                    // middle
                    middle = (ylimit + 1)/2;
                    DrawCurtainVertical(true, middle, swagArray, frameBuffer, level, (BufferHt / 2 - 1));
                    DrawCurtainVertical(false, middle, swagArray, frameBuffer, level, (BufferHt / 2 - 1));
                    break;
                case CurtainEdge.Top:
                    // top
                    DrawCurtainVertical(false, ylimit, swagArray, frameBuffer, level, (BufferHt - 1));
                    break;
            }
        }
示例#50
0
 protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
 {
     if (Shimmer && frame%2 != 0)
     {
         return;
     }
     double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
     int totalFrames = GetNumberFrames();
     var iterationFrame = frame*Iterations%(totalFrames);
     double position = GetEffectTimeIntervalPosition(iterationFrame);
     HSV hsv = HSV.FromRGB(Color.GetColorAt(position));
     for (int x = 0; x < BufferWi; x++)
     {
         for (int y = 0; y < BufferHt; y++)
         {
             var v = hsv.V;
             v = CalculateAdjustedV(v, x, y);
             v *= level;
             HSV hsv2 = hsv;
             hsv2.V = v;
             frameBuffer.SetPixel(x, y, hsv2);
         }
     }
 }
示例#51
0
文件: Curtain.cs 项目: jaredb7/vixen
        private void DrawCurtainVertical(bool topEdge, int ylimit, List<int> swagArray, IPixelFrameBuffer frameBuffer,
			double level, int width)
        {
            int i, x, y;
            for (i = 0; i < ylimit; i++)
            {
                HSV hsv = HSV.FromRGB(Color.GetColorAt((double)i / width));
                y = topEdge ? BufferHt - i - 1 : i;
                for (x = BufferWi - 1; x >= 0; x--)
                {
                    hsv.V = hsv.V*level;
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }

            // swag
            for (i = 0; i < swagArray.Count(); i++)
            {
                y = ylimit + i;
                HSV hsv = HSV.FromRGB(Color.GetColorAt((double)y / width));
                if (topEdge) y = BufferHt - y - 1;
                for (x = BufferWi - 1; x > swagArray[i]; x--)
                {
                    hsv.V = hsv.V*level;
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }
        }
示例#52
0
文件: Tree.cs 项目: jaredb7/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double level = LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
            double blendLevel = BlendCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
            double backgroundLevelCurve = BackgroundLevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;

            int x, y, mod, b;
            float V;
            int cycleLen = frame * Speed;
            int pixelsPerBranch = (int)(0.5 + (double)BufferHt / Branches);
            if (pixelsPerBranch == 0)
            {
                pixelsPerBranch = 1;
            }

            if (frame == _xLimit)
            {
                _treeWidth = 0;
                _xLimit += BufferWi;
            }
            _treeWidth++;

            for (y = 0; y < BufferHt; y++)
            {
                for (x = 0; x < BufferWi; x++)
                {
                    mod = y % pixelsPerBranch;
                    if (mod == 0) mod = pixelsPerBranch;
                    V = ToggleBlend //Fade between branches
                        ? (float) (1 - (1.0*mod/pixelsPerBranch)*(1 - blendLevel))
                        : (float) ((1.0*mod/pixelsPerBranch)*(blendLevel));

                    HSV hsv = HSV.FromRGB(BackgroundColor.GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                    hsv.V = backgroundLevelCurve * V; // we have now set the color for the background tree

                    //   $orig_rgbval=$rgb_val;
                    Branch = (int)((y - 1) / pixelsPerBranch);
                    if (_branchColor >= Colors.Count || Branch == 0)
                        _branchColor = 0;
                    _row = pixelsPerBranch - mod; // now row=0 is bottom of branch, row=1 is one above bottom
                    //  mod = which pixel we are in the branch
                    //	mod=1,row=pixels_per_branch-1   top picrl in branch
                    //	mod=2, second pixel down into branch
                    //	mod=pixels_per_branch,row=0  last pixel in branch
                    //
                    //	row = 0, the $p is in the bottom row of tree
                    //	row =1, the $p is in second row from bottom
                    b = (int)((cycleLen) / BufferWi) % Branches; // what branch we are on based on frame #
                    //
                    //	b = 0, we are on bottomow row of tree during frames 1 to BufferWi
                    //	b = 1, we are on second row from bottom, frames = BufferWi+1 to 2*BufferWi
                    //	b = 2, we are on third row from bottome, frames - 2*BufferWi+1 to 3*BufferWi

                    M = (x % 6);
                    // m=0, 1sr strand
                    // m=1, 2nd strand
                    // m=5, last strand in 6 strand pattern

                    switch (ColorType)
                    {
                        case TreeColorType.Twinkle:
                            _colorIdx = _random.Next(0, Colors.Count);
                            break;
                        case TreeColorType.AlternatePixel:
                            _colorIdx = (x % Colors.Count);
                            break;
                        case TreeColorType.Static:
                            _colorIdx = _branchColor;
                        break;
                        case TreeColorType.Alternate:
                        break;
                    }

                    switch (BranchDirection)
                    {
                            case TreeBranchDirection.UpRight:
                            case TreeBranchDirection.DownRight:
                            case TreeBranchDirection.UpLeft:
                            case TreeBranchDirection.DownLeft:
                                if (Branch <= b && x <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3)))))))
                                    hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                            break;

                            case TreeBranchDirection.Up:
                            case TreeBranchDirection.Down:
                                if (Branch <= b &&
                                (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3)))))))
                                    hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                            break;

                            case TreeBranchDirection.Left:
                                if ((BufferWi - x) <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3)))))))
                                    hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                            break;

                            case TreeBranchDirection.Alternate:
                                if (Branch%2 != 0)
                                {
                                    if ((BufferWi - x) <= _treeWidth &&  (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3)))))))
                                        hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                                }
                                else
                                {
                                    if (x <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3)))))))
                                        hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                                }
                            break;

                            case TreeBranchDirection.Right:
                            if (x <= _treeWidth && (((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3)))))))
                                hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                            break;

                            case TreeBranchDirection.None:
                                if (((((_row == 3 && (M == 0 || M == 5)) || ((_row == 2 && (M == 1 || M == 4)) || ((_row == 1 && (M == 2 || M == 3))))))))
                                    hsv = HSV.FromRGB(Colors[_colorIdx].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                            break;
                    }

                    hsv.V = hsv.V*level; //adjusts overall intensity
                    switch (BranchDirection)
                    {
                            case TreeBranchDirection.Down:
                            case TreeBranchDirection.DownRight:
                                frameBuffer.SetPixel(x, BufferHt - y, hsv);
                            break;
                            case TreeBranchDirection.UpLeft:
                                frameBuffer.SetPixel(BufferWi - x, y, hsv);
                            break;
                            case TreeBranchDirection.DownLeft:
                                frameBuffer.SetPixel(BufferWi - x, BufferHt - y, hsv);
                            break;
                            default:
                                frameBuffer.SetPixel(x, y, hsv);
                            break;
                    }
                }
                _colorIdx = (Branch % Colors.Count);
            }
        }
示例#53
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (StringCount == 1) return;

            int colorcnt = ColorGradients.Count;

            for (int i = 0; i < Particles*Explosions; i++)
            {
                if (_fireworkBursts[i].StartPeriod == frame)
                {
                    _fireworkBursts[i].Active = true;
                }

                // ... active flakes:
                if (_fireworkBursts[i].Active)
                {
                    // Update position
                    _fireworkBursts[i].X += _fireworkBursts[i].Dx;
                    _fireworkBursts[i].Y +=
                        (float) (-_fireworkBursts[i].Dy - _fireworkBursts[i].Cycles*_fireworkBursts[i].Cycles/10000000.0);
                    // If this flake run for more than maxCycle, time to switch it off
                    _fireworkBursts[i].Cycles += 20;
                    if (_fireworkBursts[i].Cycles >= MaxFlakes)
                    {
                        _fireworkBursts[i].Active = false;
                        continue;
                    }
                    // If this flake hit the earth or is out of bounds, time to switch it off
                    if (_fireworkBursts[i].Y >= BufferHt || _fireworkBursts[i].Y < 0 || _fireworkBursts[i].X < 0 || _fireworkBursts[i].X >= BufferWi)
                    {
                        _fireworkBursts[i].Active = false;
                    }
                }
            }

            double position = GetEffectTimeIntervalPosition(frame);
            double level = LevelCurve.GetValue(position * 100) / 100;
            for (int i = 0; i < MaxFlakes; i++)
            {
                if (_fireworkBursts[i].Active)
                {
                    var v = (float)(((ParticalFade * 10.0) - _fireworkBursts[i].Cycles) / (ParticalFade * 10.0));
                    if (v < 0) v = 0.0f;
                    switch (ColorType)
                    {
                        case FireworksColorType.Range: //Random two colors are selected from the list for each Firework.
                            _fireworkBursts[i].HSV =
                                SetRangeColor(HSV.FromRGB(ColorGradients[Rand() % colorcnt].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)),
                                    HSV.FromRGB(ColorGradients[Rand() % colorcnt].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100)));
                            break;
                        case FireworksColorType.Palette: //All colors are used
                            _fireworkBursts[i].HSV = HSV.FromRGB(ColorGradients[Rand() % colorcnt].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                            break;
                        case FireworksColorType.RainBow: //No user colors are used for Rainbow effect.
                            _fireworkBursts[i].HSV.H = (float)(Rand() % 1000) / 1000.0f;
                            _fireworkBursts[i].HSV.S = 1.0f;
                            _fireworkBursts[i].HSV.V = 1.0f;
                            break;
                        case FireworksColorType.Standard:
                            _fireworkBursts[i].HSV = HSV.FromRGB(ColorGradients[_fireworkBursts[i].ColorLocation].GetColorAt((GetEffectTimeIntervalPosition(frame) * 100) / 100));
                            break;
                    }
                    HSV hsv = _fireworkBursts[i].HSV;
                    hsv.V = v*level;
                    frameBuffer.SetPixel((int)_fireworkBursts[i].X, (int)_fireworkBursts[i].Y, hsv);
                }
            }
        }
示例#54
0
        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 {
            }
        }
示例#55
0
文件: Fire.cs 项目: jaredb7/vixen
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            double position = GetEffectTimeIntervalPosition(frame);
            int x, y;
            if (frame == 0)
            {
                int i;
                for (i = 0; i < _fireBuffer.Count(); i++)
                {
                    _fireBuffer[i] = 0;
                }
            }

            int maxHt = BufferHt;
            int maxWi = BufferWi;
            if (Location == FireDirection.Left || Location == FireDirection.Right)
            {
                maxHt = BufferWi;
                maxWi = BufferHt;
            }

            // build fire
            for (x = 0; x < maxWi; x++)
            {
                var r = x % 2 == 0 ? 190 + (Rand() % 10) : 100 + (Rand() % 50);
                SetFireBuffer(x, 0, r, maxWi, maxHt);
            }

            double interval = GetEffectTimeIntervalPosition(frame);

            int h = (int)Height.GetValue(interval*100);

            if(h <= 0)
            {
                h = 1;
            }
            int step = 255 * 100 / maxHt / h;

            for (y = 1; y < maxHt; y++)
            {
                for (x = 0; x < maxWi; x++)
                {
                    var v1 = GetFireBuffer(x - 1, y - 1, maxWi, maxHt);
                    var v2 = GetFireBuffer(x + 1, y - 1, maxWi, maxHt);
                    var v3 = GetFireBuffer(x, y - 1, maxWi, maxHt);
                    var v4 = GetFireBuffer(x, y - 1, maxWi, maxHt);
                    var n = 0;
                    var sum = 0;
                    if (v1 >= 0)
                    {
                        sum += v1;
                        n++;
                    }
                    if (v2 >= 0)
                    {
                        sum += v2;
                        n++;
                    }
                    if (v3 >= 0)
                    {
                        sum += v3;
                        n++;
                    }
                    if (v4 >= 0)
                    {
                        sum += v4;
                        n++;
                    }
                    var newIndex = n > 0 ? sum / n : 0;
                    if (newIndex > 0)
                    {
                        newIndex += (Rand() % 100 < 20) ? step : -step;
                        if (newIndex < 0) newIndex = 0;
                        if (newIndex >= FirePalette.Count()) newIndex = FirePalette.Count() - 1;
                    }
                    SetFireBuffer(x, y, newIndex, maxWi, maxHt);
                }
            }
            for (y = 0; y < maxHt; y++)
            {
                for (x = 0; x < maxWi; x++)
                {
                    int xp = x;
                    int yp = y;
                    if (Location == FireDirection.Top || Location == FireDirection.Right)
                    {
                        yp = maxHt - y - 1;
                    }
                    if (Location == FireDirection.Left || Location == FireDirection.Right)
                    {
                        int t = xp;
                        xp = yp;
                        yp = t;
                    }

                    Color color = FirePalette.GetColor(GetFireBuffer(x, y, maxWi, maxHt));
                    var hsv = HSV.FromRGB(color);
                    if (HueShift > 0)
                    {
                        hsv.H = hsv.H + (HueShift / 100.0f);
                    }

                    hsv.V = hsv.V * LevelCurve.GetValue(position * 100) / 100;
                    //if (color.R == 0 && color.G == 0 && color.B == 0)
                    //{
                    //	color = Color.Transparent;
                    //}

                    frameBuffer.SetPixel(xp, yp, hsv);
                }
            }
        }