void BlendAnimation2D(Effect effect, DeviceFrameIndex deviceFrameIndex, int device, Device2D device2D, string animationName,
                          int[] colors, int[] tempColors)
    {
        int size       = GetColorArraySize2D(device2D);
        int frameId    = deviceFrameIndex._mFrameIndex[device];
        int frameCount = ChromaAnimationAPI.GetFrameCountName(animationName);

        if (frameId < frameCount)
        {
            //cout << animationName << ": " << (1 + frameId) << " of " << frameCount << endl;
            float duration;
            int   animationId = ChromaAnimationAPI.GetAnimation(animationName);
            ChromaAnimationAPI.GetFrame(animationId, frameId, out duration, tempColors, size);
            for (int i = 0; i < size; ++i)
            {
                int color1    = colors[i];     //target
                int tempColor = tempColors[i]; //source

                // BLEND
                int color2;
                if (effect._mBlend == "none")
                {
                    color2 = tempColor; //source
                }
                else if (effect._mBlend == "invert")
                {
                    if (tempColor != 0)                  //source
                    {
                        color2 = InvertColor(tempColor); //source inverted
                    }
                    else
                    {
                        color2 = 0;
                    }
                }
                else if (effect._mBlend == "thresh")
                {
                    color2 = Thresh(effect._mPrimaryColor, effect._mSecondaryColor, tempColor); //source
                }
                else // if (effect._mBlend == "lerp") //default
                {
                    color2 = MultiplyNonZeroTargetColorLerp(effect._mPrimaryColor, effect._mSecondaryColor, tempColor); //source
                }

                // MODE
                if (effect._mMode == "max")
                {
                    colors[i] = MaxColor(color1, color2);
                }
                else if (effect._mMode == "min")
                {
                    colors[i] = MinColor(color1, color2);
                }
                else if (effect._mMode == "average")
                {
                    colors[i] = AverageColor(color1, color2);
                }
                else if (effect._mMode == "multiply")
                {
                    colors[i] = MultiplyColor(color1, color2);
                }
                else if (effect._mMode == "add")
                {
                    colors[i] = AddColor(color1, color2);
                }
                else if (effect._mMode == "subtract")
                {
                    colors[i] = SubtractColor(color1, color2);
                }
                else // if (effect._mMode == "replace") //default
                {
                    if (color2 != 0)
                    {
                        colors[i] = color2;
                    }
                }
            }
            deviceFrameIndex._mFrameIndex[device] = (frameId + frameCount + effect._mSpeed) % frameCount;
        }
    }
Example #2
0
        void BlendAnimation2D(FChromaSDKSceneEffect effect, FChromaSDKDeviceFrameIndex deviceFrameIndex, int device, Device2D device2D, string animationName,
                              int[] colors, int[] tempColors)
        {
            int size       = GetColorArraySize2D(device2D);
            int frameId    = deviceFrameIndex._mFrameIndex[device];
            int frameCount = ChromaAnimationAPI.GetFrameCountName(animationName);

            if (frameId < frameCount)
            {
                //cout << animationName << ": " << (1 + frameId) << " of " << frameCount << endl;
                float duration;
                int   animationId = ChromaAnimationAPI.GetAnimation(animationName);
                ChromaAnimationAPI.GetFrame(animationId, frameId, out duration, tempColors, size);
                for (int i = 0; i < size; ++i)
                {
                    int color1    = colors[i];                  //target
                    int tempColor = tempColors[i];              //source

                    // BLEND
                    int color2;
                    switch (effect._mBlend)
                    {
                    case EChromaSDKSceneBlend.SB_None:
                        color2 = tempColor;                                 //source
                        break;

                    case EChromaSDKSceneBlend.SB_Invert:
                        if (tempColor != 0)                                 //source
                        {
                            color2 = InvertColor(tempColor);                //source inverted
                        }
                        else
                        {
                            color2 = 0;
                        }
                        break;

                    case EChromaSDKSceneBlend.SB_Threshold:
                        color2 = Thresh(effect._mPrimaryColor, effect._mSecondaryColor, tempColor);                                 //source
                        break;

                    case EChromaSDKSceneBlend.SB_Lerp:
                    default:
                        color2 = MultiplyNonZeroTargetColorLerp(effect._mPrimaryColor, effect._mSecondaryColor, tempColor);                                 //source
                        break;
                    }

                    // MODE
                    switch (effect._mMode)
                    {
                    case EChromaSDKSceneMode.SM_Max:
                        colors[i] = MaxColor(color1, color2);
                        break;

                    case EChromaSDKSceneMode.SM_Min:
                        colors[i] = MinColor(color1, color2);
                        break;

                    case EChromaSDKSceneMode.SM_Average:
                        colors[i] = AverageColor(color1, color2);
                        break;

                    case EChromaSDKSceneMode.SM_Multiply:
                        colors[i] = MultiplyColor(color1, color2);
                        break;

                    case EChromaSDKSceneMode.SM_Add:
                        colors[i] = AddColor(color1, color2);
                        break;

                    case EChromaSDKSceneMode.SM_Subtract:
                        colors[i] = SubtractColor(color1, color2);
                        break;

                    case EChromaSDKSceneMode.SM_Replace:
                    default:
                        if (color2 != 0)
                        {
                            colors[i] = color2;
                        }
                        break;
                    }
                }
                deviceFrameIndex._mFrameIndex[device] = (frameId + frameCount + effect._mSpeed) % frameCount;
            }
        }