Exemple #1
0
        /// <summary>Builds the SVG as a Loonim filter.</summary>
        internal void BuildFilter()
        {
            // Clear DS:
            DrawStack = null;

            // Build up the filter:
            Drawing.BuildFilter(this);

            // Set DS as root:
            Filter.Root = DrawStack;

            if (DrawStack != null)
            {
                // PreAllocate it:
                Filter.PreAllocate(DrawInfo);
            }
        }
        /// <summary>Connects a filter to the camera's output.
        /// Fires an imagechange event too as this updates Texture to the filtered version.</summary>
        private void ConnectFilter()
        {
            if (Filter_ != null)
            {
                if (FilterDrawInfo == null)
                {
                    FilterDrawInfo = new Loonim.DrawInfo();
                }

                // Update draw info:
                FilterDrawInfo.SetSize(pixelWidth, pixelHeight);

                // Update source:
                Filter_.Set("source0", SourceCamera.targetTexture);

                // Reallocate the filter:
                Filter_.PreAllocate(FilterDrawInfo);

                // Grab the main output (always a RT):
                Texture = Filter_.Texture as RenderTexture;

                if (Texture == null)
                {
                    // This isn't a valid filter!
                    // It either had no nodes or e.g. e.g. a solid colour.
                    Debug.Log("Invalid filter was set to a FlatWorldUI - removed it.");
                    Filter_ = null;
                }
            }

            if (Filter_ == null)
            {
                // Clear draw info:
                FilterDrawInfo = null;

                // Revert to the camera's output:
                Texture = SourceCamera.targetTexture;
            }

            // Fire an imagechange event into the window:
            Dom.Event e = new Dom.Event("imagechange");
            e.SetTrusted(false);
            document.window.dispatchEvent(e);
        }