Пример #1
0
        public static void DrawRoundedBlurPanelBackgroundPart(IBatchRenderer sbatch, FRectangle bounds, float cornerSize = 16f, float alpha = 1f)
        {
            StaticTextures.ThrowIfNotInitialized();

            var alphaWhite = Color.White * alpha;
            var alphaBlack = Color.Black * alpha;

            var r_tl = new FRectangle(bounds.Left - cornerSize, bounds.Top - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_tr = new FRectangle(bounds.Right - cornerSize, bounds.Top - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_br = new FRectangle(bounds.Right - cornerSize, bounds.Bottom - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_bl = new FRectangle(bounds.Left - cornerSize, bounds.Bottom - cornerSize, 2 * cornerSize, 2 * cornerSize);

            var r_l = new FRectangle(r_tl.Left, r_tl.Bottom, r_tl.Width, r_bl.Top - r_tl.Bottom);
            var r_t = new FRectangle(r_tl.Right, r_tl.Top, r_tr.Left - r_tl.Right, r_tl.Height);
            var r_r = new FRectangle(r_tr.Left, r_tr.Bottom, r_tr.Width, r_br.Top - r_tr.Bottom);
            var r_b = new FRectangle(r_bl.Right, r_bl.Top, r_br.Left - r_bl.Right, r_bl.Height);

            // Top
            sbatch.DrawRot000(StaticTextures.PanelBlurEdge, r_t, alphaWhite, 0);

            // Right
            sbatch.DrawRot090(StaticTextures.PanelBlurEdge, r_r, alphaWhite, 0);

            // Bottom
            sbatch.DrawRot180(StaticTextures.PanelBlurEdge, r_b, alphaWhite, 0);

            // Left
            sbatch.DrawRot270(StaticTextures.PanelBlurEdge, r_l, alphaWhite, 0);

            // TL
            sbatch.DrawRot000(StaticTextures.PanelBlurCorner, r_tl, alphaWhite, 0);

            // TR
            sbatch.DrawRot090(StaticTextures.PanelBlurCorner, r_tr, alphaWhite, 0);

            // BR
            sbatch.DrawRot180(StaticTextures.PanelBlurCorner, r_br, alphaWhite, 0);

            // BL
            sbatch.DrawRot270(StaticTextures.PanelBlurCorner, r_bl, alphaWhite, 0);

            sbatch.FillRectangle(r_tl.BottomRight, new FSize(bounds.Width - 2 * cornerSize, bounds.Height - 2 * cornerSize), alphaBlack);
        }
Пример #2
0
        public static void DrawAligned9Patch(IBatchRenderer sbatch, FRectangle bounds, Color colEdge, Color colCorner, Color colFill, TextureRegion2D texEdge, TextureRegion2D texCorner, TextureRegion2D texFill, float cornerSize)
        {
            var r_tl = new FRectangle(bounds.Left - cornerSize, bounds.Top - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_tr = new FRectangle(bounds.Right - cornerSize, bounds.Top - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_br = new FRectangle(bounds.Right - cornerSize, bounds.Bottom - cornerSize, 2 * cornerSize, 2 * cornerSize);
            var r_bl = new FRectangle(bounds.Left - cornerSize, bounds.Bottom - cornerSize, 2 * cornerSize, 2 * cornerSize);

            var r_l = new FRectangle(r_tl.Left, r_tl.Bottom, r_tl.Width, r_bl.Top - r_tl.Bottom);
            var r_t = new FRectangle(r_tl.Right, r_tl.Top, r_tr.Left - r_tl.Right, r_tl.Height);
            var r_r = new FRectangle(r_tr.Left, r_tr.Bottom, r_tr.Width, r_br.Top - r_tr.Bottom);
            var r_b = new FRectangle(r_bl.Right, r_bl.Top, r_br.Left - r_bl.Right, r_bl.Height);

            var r_c = new FRectangle(bounds.Left + cornerSize, bounds.Top + cornerSize, bounds.Width - 2 * cornerSize, bounds.Height - 2 * cornerSize);

            // Top
            sbatch.DrawRot000(texEdge, r_t, colEdge, 0);

            // Right
            sbatch.DrawRot090(texEdge, r_r, colEdge, 0);

            // Bottom
            sbatch.DrawRot180(texEdge, r_b, colEdge, 0);

            // Left
            sbatch.DrawRot270(texEdge, r_l, colEdge, 0);

            // TL
            sbatch.DrawRot000(texCorner, r_tl, colCorner, 0);

            // TR
            sbatch.DrawRot090(texCorner, r_tr, colCorner, 0);

            // BR
            sbatch.DrawRot180(texCorner, r_br, colCorner, 0);

            // BL
            sbatch.DrawRot270(texCorner, r_bl, colCorner, 0);

            // Center
            sbatch.DrawStretched(texFill, r_c, colFill, 0);
        }
Пример #3
0
        public static void DrawForegroundDropShadow(IBatchRenderer sbatch, FRectangle bounds, float sOutset, float sInset)
        {
            StaticTextures.ThrowIfNotInitialized();

            var r_tl = new FRectangle(bounds.Left - sOutset, bounds.Top - sOutset, sOutset + sInset, sOutset + sInset);
            var r_tr = new FRectangle(bounds.Right - sInset, bounds.Top - sOutset, sOutset + sInset, sOutset + sInset);
            var r_br = new FRectangle(bounds.Right - sInset, bounds.Bottom - sInset, sOutset + sInset, sOutset + sInset);
            var r_bl = new FRectangle(bounds.Left - sOutset, bounds.Bottom - sInset, sOutset + sInset, sOutset + sInset);

            var r_l = new FRectangle(r_tl.Left, r_tl.Bottom, r_tl.Width, r_bl.Top - r_tl.Bottom);
            var r_t = new FRectangle(r_tl.Right, r_tl.Top, r_tr.Left - r_tl.Right, r_tl.Height);
            var r_r = new FRectangle(r_tr.Left, r_tr.Bottom, r_tr.Width, r_br.Top - r_tr.Bottom);
            var r_b = new FRectangle(r_bl.Right, r_bl.Top, r_br.Left - r_bl.Right, r_bl.Height);

            // Top
            sbatch.DrawRot000(StaticTextures.PanelBlurEdgePrecut, r_t, Color.White, 0);

            // Right
            sbatch.DrawRot090(StaticTextures.PanelBlurEdgePrecut, r_r, Color.White, 0);

            // Bottom
            sbatch.DrawRot180(StaticTextures.PanelBlurEdgePrecut, r_b, Color.White, 0);

            // Left
            sbatch.DrawRot270(StaticTextures.PanelBlurEdgePrecut, r_l, Color.White, 0);

            // TL
            sbatch.DrawRot000(StaticTextures.PanelBlurCornerPrecut, r_tl, Color.White, 0);

            // TR
            sbatch.DrawRot090(StaticTextures.PanelBlurCornerPrecut, r_tr, Color.White, 0);

            // BR
            sbatch.DrawRot180(StaticTextures.PanelBlurCornerPrecut, r_br, Color.White, 0);

            // BL
            sbatch.DrawRot270(StaticTextures.PanelBlurCornerPrecut, r_bl, Color.White, 0);
        }
Пример #4
0
		public static void DrawDropShadow(IBatchRenderer sbatch, FRectangle bounds, float sOutset, float sInset)
		{
			StaticTextures.ThrowIfNotInitialized();

			var r_tl = new FRectangle(
				bounds.Left - sOutset,
				bounds.Top - sOutset,
				sOutset + sInset,
				sOutset + sInset).Round();

			var r_tr = new FRectangle(
				bounds.Right - sInset,
				bounds.Top - sOutset,
				sOutset + sInset,
				sOutset + sInset).Round();

			var r_br = new FRectangle(
				bounds.Right - sInset,
				bounds.Bottom - sInset,
				sOutset + sInset,
				sOutset + sInset).Round();

			var r_bl = new FRectangle(
				bounds.Left - sOutset,
				bounds.Bottom - sInset,
				sOutset + sInset,
				sOutset + sInset).Round();

			var r_l = new Rectangle(r_tl.Left, r_tl.Bottom, r_tl.Width, r_bl.Top - r_tl.Bottom);

			var r_t = new Rectangle(r_tl.Right, r_tl.Top, r_tr.Left - r_tl.Right, r_tl.Height);

			var r_r = new Rectangle(r_tr.Left, r_tr.Bottom, r_tr.Width, r_br.Top - r_tr.Bottom);

			var r_b = new Rectangle(r_bl.Right, r_bl.Top, r_br.Left - r_bl.Right, r_bl.Height);
			
			// Top
			sbatch.DrawRot000(StaticTextures.PanelBlurEdge.Texture, r_t, StaticTextures.PanelBlurEdge.Bounds, Color.White, 0);

			// Right
			sbatch.DrawRot090(StaticTextures.PanelBlurEdge.Texture, r_r, StaticTextures.PanelBlurEdge.Bounds, Color.White, 0);

			// Bottom
			sbatch.DrawRot180(StaticTextures.PanelBlurEdge.Texture, r_b, StaticTextures.PanelBlurEdge.Bounds, Color.White, 0);

			// Left
			sbatch.DrawRot270(StaticTextures.PanelBlurEdge.Texture, r_l, StaticTextures.PanelBlurEdge.Bounds, Color.White, 0);
			
			// TL
			sbatch.DrawRot000(StaticTextures.PanelBlurCorner.Texture, r_tl, StaticTextures.PanelBlurCorner.Bounds, Color.White, 0);

			// TR
			sbatch.DrawRot090(StaticTextures.PanelBlurCorner.Texture, r_tr, StaticTextures.PanelBlurCorner.Bounds, Color.White, 0);

			// BR
			sbatch.DrawRot180(StaticTextures.PanelBlurCorner.Texture, r_br, StaticTextures.PanelBlurCorner.Bounds, Color.White, 0);

			// BL
			sbatch.DrawRot270(StaticTextures.PanelBlurCorner.Texture, r_bl, StaticTextures.PanelBlurCorner.Bounds, Color.White, 0);
		}
Пример #5
0
        public static void DrawRoundedRect(IBatchRenderer sbatch, FRectangle bounds, Color color, bool tl, bool tr, bool bl, bool br, float cornerSize = 16f)
        {
            StaticTextures.ThrowIfNotInitialized();

            if (!tl && !tr && !bl && !br)
            {
                DrawSimpleRect(sbatch, bounds, color);
                return;
            }

            #region Fill Center

            if (color.A == 255)
            {
                sbatch.DrawStretched(
                    StaticTextures.SinglePixel,
                    bounds.AsDeflated(cornerSize, 0),
                    color);

                sbatch.DrawStretched(
                    StaticTextures.SinglePixel,
                    bounds.AsDeflated(0, cornerSize),
                    color);
            }
            else
            {
                sbatch.DrawStretched(
                    StaticTextures.SinglePixel,
                    bounds.AsDeflated(cornerSize, 0),
                    color);

                sbatch.DrawStretched(
                    StaticTextures.SinglePixel,
                    bounds.ToSubRectangle(cornerSize, bounds.Height - 2 * cornerSize, FlatAlign9.WEST),
                    color);

                sbatch.DrawStretched(
                    StaticTextures.SinglePixel,
                    bounds.ToSubRectangle(cornerSize, bounds.Height - 2 * cornerSize, FlatAlign9.EAST),
                    color);
            }


            #endregion

            #region Corners

            var r_tl = bounds.ToSquare(cornerSize, FlatAlign9.TL);
            var r_tr = bounds.ToSquare(cornerSize, FlatAlign9.TR);
            var r_br = bounds.ToSquare(cornerSize, FlatAlign9.BR);
            var r_bl = bounds.ToSquare(cornerSize, FlatAlign9.BL);

            if (tl)
            {
                sbatch.DrawRot000(StaticTextures.PanelCorner, r_tl, color, 0);
            }
            else
            {
                sbatch.DrawRot000(StaticTextures.SinglePixel, r_tl, color, 0);
            }

            if (tr)
            {
                sbatch.DrawRot090(StaticTextures.PanelCorner, r_tr, color, 0);
            }
            else
            {
                sbatch.DrawRot090(StaticTextures.SinglePixel, r_tr, color, 0);
            }

            if (br)
            {
                sbatch.DrawRot180(StaticTextures.PanelCorner, r_br, color, 0);
            }
            else
            {
                sbatch.DrawRot180(StaticTextures.SinglePixel, r_br, color, 0);
            }

            if (bl)
            {
                sbatch.DrawRot270(StaticTextures.PanelCorner, r_bl, color, 0);
            }
            else
            {
                sbatch.DrawRot270(StaticTextures.SinglePixel, r_bl, color, 0);
            }

            #endregion
        }