Пример #1
0
        /// <inheritdoc />
        /// <summary>
        ///      Creates a new blur container
        /// </summary>
        public BlurContainer(BlurType blurType, float strength)
        {
            // ReSharper disable once ArrangeConstructorOrDestructorBody
            SpriteBatchOptions = new SpriteBatchOptions()
            {
                SortMode          = SpriteSortMode.Deferred,
                BlendState        = BlendState.NonPremultiplied,
                SamplerState      = SamplerState.PointClamp,
                DepthStencilState = DepthStencilState.Default,
                RasterizerState   = RasterizerState.CullNone,
            };

            // Load all three shaders.
            BlurEffects = new Dictionary <BlurType, Effect>
            {
                { BlurType.Gaussian, new Effect(GameBase.Game.GraphicsDevice, GameBase.Game.Resources.Get("Wobble.Resources/Shaders/gaussian-blur.mgfxo")) },
                { BlurType.Frosty, new Effect(GameBase.Game.GraphicsDevice, GameBase.Game.Resources.Get("Wobble.Resources/Shaders/frosty-blur.mgfxo")) },
                { BlurType.Fast, new Effect(GameBase.Game.GraphicsDevice, GameBase.Game.Resources.Get("Wobble.Resources/Shaders/fast-blur.mgfxo")) },
            };

            BlurType = blurType;
            Strength = strength;

            SpriteBatchOptions.Shader = new Shader(BlurEffects[BlurType], new Dictionary <string, object>
            {
                { "p_blurValues", new Vector3(Width, Height, Strength) }
            });
        }
Пример #2
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public SpriteMaskContainer()
        {
            MaskDepthStencilState = new DepthStencilState
            {
                StencilEnable     = true,
                StencilFunction   = CompareFunction.Always,
                StencilPass       = StencilOperation.Replace,
                ReferenceStencil  = 1,
                DepthBufferEnable = false,
            };

            ContainedDepthStencilState = new DepthStencilState
            {
                StencilEnable     = true,
                StencilFunction   = CompareFunction.LessEqual,
                StencilPass       = StencilOperation.Keep,
                ReferenceStencil  = 1,
                DepthBufferEnable = false,
            };

            Matrix = Matrix.CreateOrthographicOffCenter(0, WindowManager.Width, WindowManager.Height, 0, 0, 1);

            MaskAlphaTestEffect = new AlphaTestEffect(GameBase.Game.Graphics.GraphicsDevice)
            {
                Projection = Matrix,
            };

            SpriteBatchOptions = new SpriteBatchOptions
            {
                DepthStencilState = MaskDepthStencilState,
                Shader            = new Shader(MaskAlphaTestEffect, new Dictionary <string, object>())
            };
        }
Пример #3
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        public ScrollContainer(ScalableVector2 size, ScalableVector2 contentSize, bool startFromBottom = false)
        {
            Size = size;

            // Create the SpriteBatchOptions with scissor rect enabled.
            SpriteBatchOptions = new SpriteBatchOptions
            {
                SortMode        = SpriteSortMode.Immediate,
                BlendState      = BlendState.NonPremultiplied,
                RasterizerState = new RasterizerState
                {
                    ScissorTestEnable = true,
                },
            };

            // Create container in which all scrolling contents will be children of.
            ContentContainer = new Container(contentSize, new ScalableVector2(0, 0))
            {
                Parent = this,
                UsePreviousSpriteBatchOptions = true
            };

            // Choose starting location of the scroll container
            ContentContainer.Y = startFromBottom ? -ContentContainer.Height : 0;

            // Create the scroll bar.
            Scrollbar = new Sprite
            {
                Parent    = this,
                Alignment = Alignment.BotRight,
                Width     = 15,
                Tint      = Color.Black,
                X         = 1
            };

            TargetY         = ContentContainer.Y;
            PreviousTargetY = TargetY;
        }