コード例 #1
0
        private void OnRender_BackgroundSolidTexture(
            DrawingContext dc,
            ImageSource topStatic,
            ImageSource topDynamic,
            float textureOpacity,
            Color background,
            float gradient)
        {
            SetEnableWarp(true);

            var opaque = background;
            var faded = background.Blend(Colors.White, gradient);
            //LinearGradientBrush lgBrush = new LinearGradientBrush(faded, opaque, 90);
            var lgBrush = RenderToolFactory.GetTool<Brush>(new LinearGradientBrushTool(faded, opaque, 90));
            dc.DrawRectangle(lgBrush, null, ScreenArea);

            const int SQ_WIDTH = 66;
            const int SQ_HEIGHT = 66;
            const int SQ_X_OFF = SQ_WIDTH / 3;
            const int SQ_Y_OFF = SQ_HEIGHT / 3;

            var stBrush = RenderToolFactory.GetTool<Brush>
                (new ImageBrushTool(topStatic,
                    TileMode.Tile,
                    new Rect(-SQ_X_OFF, SQ_Y_OFF, SQ_WIDTH, SQ_HEIGHT),
                    BrushMappingMode.Absolute,
                    textureOpacity));
            dc.DrawRectangle(stBrush, null, ScreenArea);

            var off = _isListening
                          ? CompositionTargetEx.SecondsFromStart * 4
                          : (int) (SQ_WIDTH / 2);

            // Dynamic Brush is Constantly Changing
            const float WARP = (float) SQ_WIDTH / SQ_HEIGHT;
            ImageBrush dyBrush = new ImageBrush(topDynamic)
            {
                TileMode = TileMode.Tile,
                ViewportUnits = BrushMappingMode.Absolute,
                Viewport = new Rect(off * WARP - SQ_X_OFF, off + SQ_Y_OFF, SQ_WIDTH, SQ_HEIGHT),
                Opacity = textureOpacity
            };
            dc.DrawRectangle(dyBrush, null, ScreenArea);

            OnRender_3DCorners(dc);
        }