Exemple #1
0
        protected EffectIntents RenderNodeByStrings(ElementNode node)
        {
            EffectIntents effectIntents = new EffectIntents();
            int nFrames = GetNumberFrames();
            if (nFrames <= 0 | BufferWi==0 || BufferHt==0) return effectIntents;
            var buffer = new PixelFrameBuffer(BufferWi, BufferHt, UseBaseColor?BaseColor:Color.Transparent);

            int bufferSize = StringPixelCounts.Sum();

            TimeSpan startTime = TimeSpan.Zero;

            // set up arrays to hold the generated colors
            var pixels = new RGBValue[bufferSize][];
            for (int eidx = 0; eidx < bufferSize; eidx++)
                pixels[eidx] = new RGBValue[nFrames];

            // generate all the pixels
            for (int frameNum = 0; frameNum < nFrames; frameNum++)
            {
                if (UseBaseColor)
                {
                    var level = BaseLevelCurve.GetValue(GetEffectTimeIntervalPosition(frameNum)*100)/100;
                    buffer.ClearBuffer(level);
                }
                else
                {
                    buffer.ClearBuffer();
                }

                RenderEffect(frameNum, buffer);
                // peel off this frames pixels...
                if (StringOrientation == StringOrientation.Horizontal)
                {
                    int i = 0;
                    for (int y = 0; y < BufferHt; y++)
                    {
                        for (int x = 0; x < StringPixelCounts[y]; x++)
                        {
                            if (i >= pixels.Length) break;
                            pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x,y));
                            i++;
                        }
                    }
                }
                else
                {
                    int i = 0;
                    for (int x = 0; x < BufferWi; x++)
                    {
                        for (int y = 0; y < StringPixelCounts[x]; y++)
                        {
                            if (i >= pixels.Length) break;
                            pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x, y));
                            i++;
                        }
                    }
                }
            }

            // create the intents
            var frameTs = new TimeSpan(0, 0, 0, 0, FrameTime);
            List<Element> elements = node.ToList();
            int numElements = node.Count();
            for (int eidx = 0; eidx < numElements; eidx++)
            {
                IIntent intent = new StaticArrayIntent<RGBValue>(frameTs, pixels[eidx], TimeSpan);
                effectIntents.AddIntentForElement(elements[eidx].Id, intent, startTime);
            }

            return effectIntents;
        }
Exemple #2
0
        protected EffectIntents RenderNodeByStrings(ElementNode node, ref EffectIntents effectIntents)
        {
            int nFrames = GetNumberFrames();

            if (nFrames <= 0 | BufferWi == 0 || BufferHt == 0)
            {
                return(new EffectIntents());
            }
            var buffer = new PixelFrameBuffer(BufferWi, BufferHt, UseBaseColor?BaseColor:Color.Transparent);

            int bufferSize = StringPixelCounts.Sum();

            TimeSpan startTime = TimeSpan.Zero;

            // set up arrays to hold the generated colors
            var pixels = new RGBValue[bufferSize][];

            for (int eidx = 0; eidx < bufferSize; eidx++)
            {
                pixels[eidx] = new RGBValue[nFrames];
            }

            // generate all the pixels
            for (int frameNum = 0; frameNum < nFrames; frameNum++)
            {
                if (UseBaseColor)
                {
                    var level = BaseLevelCurve.GetValue(GetEffectTimeIntervalPosition(frameNum) * 100) / 100;
                    buffer.ClearBuffer(level);
                }
                else
                {
                    buffer.ClearBuffer();
                }

                RenderEffect(frameNum, buffer);
                // peel off this frames pixels...
                if (StringOrientation == StringOrientation.Horizontal)
                {
                    int i = 0;
                    for (int y = 0; y < BufferHt; y++)
                    {
                        for (int x = 0; x < StringPixelCounts[y]; x++)
                        {
                            if (i >= pixels.Length)
                            {
                                break;
                            }
                            pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x, y));
                            i++;
                        }
                    }
                }
                else
                {
                    int i = 0;
                    for (int x = 0; x < BufferWi; x++)
                    {
                        for (int y = 0; y < StringPixelCounts[x]; y++)
                        {
                            if (i >= pixels.Length)
                            {
                                break;
                            }
                            pixels[i][frameNum] = new RGBValue(buffer.GetColorAt(x, y));
                            i++;
                        }
                    }
                }
            }

            // create the intents
            var frameTs     = new TimeSpan(0, 0, 0, 0, FrameTime);
            var elements    = _elementsCached?_cachedElements:node.Distinct().ToList();
            int numElements = elements.Count;

            for (int eidx = 0; eidx < numElements; eidx++)
            {
                IIntent intent = new StaticArrayIntent <RGBValue>(frameTs, pixels[eidx], TimeSpan);
                effectIntents.AddIntentForElement(elements[eidx].Id, intent, startTime);
            }

            return(effectIntents);
        }