Esempio n. 1
0
        void SetAmbientColor1D(Device1D device, int[] colors, int ambientColor)
        {
            int size = GetColorArraySize1D(device);

            for (int i = 0; i < size; ++i)
            {
                if (colors[i] == 0)
                {
                    colors[i] = ambientColor;
                }
            }
        }
Esempio n. 2
0
        void SetupAnimation1D(string path, Device1D device)
        {
            int animationId = ChromaAnimationAPI.GetAnimation(path);

            if (animationId == -1)
            {
                animationId = ChromaAnimationAPI.CreateAnimationInMemory((int)DeviceType.DE_1D, (int)device);
                ChromaAnimationAPI.CopyAnimation(animationId, path);
                ChromaAnimationAPI.CloseAnimation(animationId);
                ChromaAnimationAPI.MakeBlankFramesName(path, 1, 0.1f, 0);
            }
        }
Esempio n. 3
0
        void BlendAnimation1D(FChromaSDKSceneEffect effect, FChromaSDKDeviceFrameIndex deviceFrameIndex, int device, Device1D device1d, string animationName,
                              int[] colors, int[] tempColors)
        {
            int size       = GetColorArraySize1D(device1d);
            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;
            }
        }
Esempio n. 4
0
        int GetColorArraySize1D(Device1D device)
        {
            int maxLeds = ChromaAnimationAPI.GetMaxLeds(device);

            return(maxLeds);
        }
        void BlendAnimation1D(Effect effect, DeviceFrameIndex deviceFrameIndex, int device, Device1D device1d, string animationName,
                              int[] colors, int[] tempColors)
        {
            int size       = GetColorArraySize1D(device1d);
            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;
            }
        }