コード例 #1
0
ファイル: GUIHelper.cs プロジェクト: kzenstratus/VRDisco
		public static void DrawRectFillAlpha(Rect rect, Color color, float alpha)
		{
			Color guiColor = GUI.color;
			
			GUI.color = color.Alpha(alpha);
			GUI.DrawTexture(rect, wHiteTex);
			
			GUI.color = color.Alpha(1);
			GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, 1+0*rect.height), wHiteTex);
			GUI.DrawTexture(new Rect(rect.x, rect.y, 1+0*rect.width, rect.height), wHiteTex);
			GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -rect.width, -1+0*rect.height), wHiteTex);
			GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -1+0*rect.width, -rect.height), wHiteTex);
			
			GUI.color = guiColor;
		}
コード例 #2
0
        public static void DrawRectFillAlpha(Rect rect, Color color, float alpha)
        {
            Color guiColor = GUI.color;

            GUI.color = color.Alpha(alpha);
            GUI.DrawTexture(rect, wHiteTex);

            GUI.color = color.Alpha(1);
            GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, 1 + 0 * rect.height), wHiteTex);
            GUI.DrawTexture(new Rect(rect.x, rect.y, 1 + 0 * rect.width, rect.height), wHiteTex);
            GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -rect.width, -1 + 0 * rect.height), wHiteTex);
            GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -1 + 0 * rect.width, -rect.height), wHiteTex);

            GUI.color = guiColor;
        }
コード例 #3
0
        public XDStyles()
        {
            // TextField
            Field                    = new GUIStyle(EditorStyles.textField);
            Field.alignment          = TextAnchor.MiddleLeft;
            Field.normal.textColor   = Normal;
            Field.normal.background  = XDUtility.CreateColoredTexture(Skin);
            Field.focused.textColor  = Normal;
            Field.focused.background = XDUtility.CreateColoredTexture(Highlight.Alpha(0.2f));
            Field.border             = new RectOffset(4, 0, 0, 0);
            Field.margin             = new RectOffset(4, 4, 4, 4);

            // Label
            Label = new GUIStyle(Field);

            Horiz_Small             = new GUIStyle(Field);
            Horiz_Small.fixedWidth  = (int)XDSizes.Small * 3;
            Horiz_Small.fixedHeight = (int)XDSizes.Small;

            Horiz_Medium             = new GUIStyle(Field);
            Horiz_Medium.fixedWidth  = (int)XDSizes.Medium * 3;
            Horiz_Medium.fixedHeight = (int)XDSizes.Small;

            Horiz_Large             = new GUIStyle(Field);
            Horiz_Large.fixedWidth  = (int)XDSizes.Large * 3;
            Horiz_Large.fixedHeight = (int)XDSizes.Small;
        }
コード例 #4
0
 public GeometryAdornment(Color color, Geometry geometry, double thickness)
 {
     _child = new DrawingVisual();
     using (var context = _child.RenderOpen()) {
         context.DrawGeometry(new SolidColorBrush(color.Alpha(25)), thickness < 0.1 ? null : new Pen(ThemeHelper.MenuHoverBorderBrush, thickness), geometry);
     }
     AddVisualChild(_child);
 }
コード例 #5
0
        public static void DrawRectFillPCAlpha(Rect rect, Color color, float alpha, float pc)
        {
            Color guiColor = GUI.color;

            float w  = rect.width * pc;
            float iw = rect.width - w;

            GUI.color = color.Alpha(alpha);
            GUI.DrawTexture(new Rect(rect.x + w, rect.y, iw, rect.height), wHiteTex);

            GUI.color = color.Alpha(1);

            GUI.DrawTexture(new Rect(rect.x, rect.y, w, rect.height), wHiteTex);

            GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, 1 + 0 * rect.height), wHiteTex);
            GUI.DrawTexture(new Rect(rect.x, rect.y, 1 + 0 * rect.width, rect.height), wHiteTex);
            GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -rect.width, -1 + 0 * rect.height), wHiteTex);
            GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -1 + 0 * rect.width, -rect.height), wHiteTex);

            GUI.color = guiColor;
        }
コード例 #6
0
ファイル: GUIHelper.cs プロジェクト: kzenstratus/VRDisco
		public static void DrawRectFillPCAlpha(Rect rect, Color color, float alpha, float pc)
		{
			Color guiColor = GUI.color;
			
			float w = rect.width * pc;
			float iw = rect.width - w;
			
			GUI.color = color.Alpha(alpha);
			GUI.DrawTexture(new Rect(rect.x + w, rect.y, iw, rect.height), wHiteTex);
			
			GUI.color = color.Alpha(1);
			
			GUI.DrawTexture(new Rect(rect.x, rect.y, w, rect.height), wHiteTex);
			
			GUI.DrawTexture(new Rect(rect.x, rect.y, rect.width, 1+0*rect.height), wHiteTex);
			GUI.DrawTexture(new Rect(rect.x, rect.y, 1+0*rect.width, rect.height), wHiteTex);
			GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -rect.width, -1+0*rect.height), wHiteTex);
			GUI.DrawTexture(new Rect(rect.x + rect.width, rect.y + rect.height, -1+0*rect.width, -rect.height), wHiteTex);
			
			GUI.color = guiColor;
		}
コード例 #7
0
        void SetColor(Color color)
        {
            _SelectedColor = color;
            var bmp = Image as Bitmap;

            using (var g = Graphics.FromImage(bmp))
                using (var b = new SolidBrush(color.A == 0 ? SystemColors.Control : color.Alpha(255))) {
                    g.DrawRectangle(Pens.DarkGray, 0, 0, bmp.Width - 1, bmp.Height - 1);
                    g.FillRectangle(b, 1, 1, bmp.Width - 2, bmp.Height - 2);
                }
            Invalidate();
        }
コード例 #8
0
ファイル: CombatState.cs プロジェクト: PurelySimple/Vrax
        private void OnPlayerDestroyed(Entity obj)
        {
            var display = Vrax.Game.Display;
            var screen  = Vrax.Game.Screen;

            var gameOverText = new Textfield(DefaultFont, "GAME OVER")
            {
                Parent   = display,
                Position = screen.Half,
                Anchor   = Distance.Center,
                Color    = Color.Alpha(0)
            };

            Vrax.Game.Animator.AddSequence(new[]
            {
                gameOverText.ColorTo(Color.White, 800),
                new DelayTween(2500),
                new ActionTween(() => gameOverText.Parent = null),
                new ActionTween(ReturnToMenu)
            });
        }
コード例 #9
0
        public static Texture2D MakeOutline(this Texture2D texture, int width)
        {
            Color[] c  = texture.GetPixels();
            Color[] nc = new Color[c.Length];

            for (int y = 0; y < texture.height; y++)
            {
                for (int x = 0; x < texture.width; x++)
                {
                    Color cc = c[x + y * texture.width];
                    if (cc.a < 0.1)
                    {
                        float a = 0;
                        for (int cy = Mathf.Max(y - width, 0); cy <= Mathf.Min(y + width, texture.height - 1); cy++)
                        {
                            for (int cx = Mathf.Max(x - width, 0); cx <= Mathf.Min(x + width, texture.width - 1); cx++)
                            {
                                a = Mathf.Max(c[cx + cy * texture.width].a, a);
                            }
                        }

                        if (a > 0.1)
                        {
                            nc[x + y * texture.width] = Color.black.Alpha(a);
                            goto skip;
                        }
                    }
                    if (cc.a > 0)
                    {
                        cc = cc.Alpha(1.0f);
                    }
                    nc[x + y * texture.width] = cc;
                    skip :;
                }
            }

            texture.SetPixels(nc, 0);
            texture.Apply();
            return(texture);
        }
コード例 #10
0
        /// <summary>
        /// Draw a group of rects in text area. Like selection rects or tag rects.
        /// </summary>
        private void DrawRects(Rect[] rects, bool flatStyle, Color color)
        {
            if (rects == null)
            {
                return;
            }

            for (int i = 0; i < rects.Length; i++)
            {
                Rect r = rects[i];
                r.y -= scroll.y;

                if (flatStyle)
                {
                    Utils.FlatRect(r, color.Alpha(0.7f), 0.2f, 0.0f);
                }
                else
                {
                    EditorGUI.DrawRect(r, color);
                }
            }
        }
コード例 #11
0
        public void Update(double deltaTime)
        {
            if (CooldownTimer > 0)
            {
                CooldownTimer -= deltaTime;
                if (CooldownTimer < 0)
                {
                    CooldownTimer = 0;

                    foreach (var renderer in Renderers)
                    {
                        renderer.Tint = Color.White;
                    }
                }
                else
                {
                    foreach (var renderer in Renderers)
                    {
                        renderer.Tint = Color.Alpha(0.40f); // Ghost the image
                    }
                }
            }
        }
コード例 #12
0
ファイル: RgbFunction.cs プロジェクト: JasonCline/dotless
        private INode AddAlphaToColor(Color color, Number number)
        {
            var alpha = GetAlphaValue(number);

            return color.Alpha(alpha);
        }
コード例 #13
0
            private static void DrawILS(ref MySpriteDrawFrame Frame, IMyTextSurface Surface, ILSDataSet ILSData)
            {
                if (ILSData.Rotation == null)
                {
                    DrawCross(ref Frame);
                    return;
                }


                // Vars
                float CircleSize  = Size.Y * 0.95f;
                float ArrowLength = Size.Y * 0.8f;

                float ArrowRotation = (float)ILSData.Rotation;
                float Deviation     = (float)ILSData.LocalizerDeviation; // between -12 and 12.

                // Re-position the Center position a bit offset in order to accomodate glideslope indicator.
                Center -= CenterSub;

                // Circle
                MySprite Circle1 = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize));

                Circle1.Color = CockpitFGColor.Alpha(1f);
                Frame.Add(Circle1);

                MySprite Circle2 = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize) * 0.95f);

                Circle2.Color = CockpitBGColor.Alpha(1f);
                Frame.Add(Circle2);

                // Arrow
                MySprite ArrowBody = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, ArrowLength)); // new Vector2(10 * UnitX, 60 * UnitY)

                ArrowBody.Color           = Color.LawnGreen.Alpha(1f);
                ArrowBody.RotationOrScale = ToRadian(ArrowRotation);
                Frame.Add(ArrowBody);

                float AConstant = ArrowLength / 2.1f;
                float Ax        = (float)Math.Sin(ToRadian(ArrowRotation)) * AConstant;
                float Ay        = (float)Math.Cos(ToRadian(ArrowRotation)) * AConstant * -1;

                MySprite ArrowHead = MySprite.CreateSprite("Triangle", Center + new Vector2(Ax, Ay), Size * 0.2f);

                ArrowHead.Color           = Color.LawnGreen.Alpha(1f);
                ArrowHead.RotationOrScale = ToRadian(ArrowRotation);
                Frame.Add(ArrowHead);


                // Deviation bar
                float DConstant = Deviation / (float)LOCFullScaleDeflectionAngle * (Size.Y * 0.4f);
                float Dx        = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DConstant * -1;
                float Dy        = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DConstant;

                MySprite DeviationBarMask = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, ArrowLength / 2.7f));

                DeviationBarMask.Color           = CockpitBGColor.Alpha(1f);
                DeviationBarMask.RotationOrScale = ToRadian(ArrowRotation);
                Frame.Add(DeviationBarMask);

                MySprite DeviationBar = MySprite.CreateSprite("SquareSimple", Center + new Vector2(Dx, Dy), new Vector2(12 * UnitX, ArrowLength / 3));

                DeviationBar.Color           = Color.LawnGreen.Alpha(1f);
                DeviationBar.RotationOrScale = ToRadian(ArrowRotation);
                Frame.Add(DeviationBar);



                // Localizer Deviation Scale
                float DSM2 = -1.0f * (Size.Y * 0.4f);
                float DSM1 = -0.5f * (Size.Y * 0.4f);
                float DSP1 = 0.5f * (Size.Y * 0.4f);
                float DSP2 = 1.0f * (Size.Y * 0.4f);


                float DSM2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM2 * -1;
                float DSM2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM2;

                float DSM1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM1 * -1;
                float DSM1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM1;

                float DSP1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP1 * -1;
                float DSP1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP1;

                float DSP2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP2 * -1;
                float DSP2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP2;

                MySprite DSM2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM2x, DSM2y), new Vector2(CircleSize, CircleSize) * 0.1f);
                MySprite DSM1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM1x, DSM1y), new Vector2(CircleSize, CircleSize) * 0.1f);
                MySprite DSCSprite  = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize) * 0.1f);
                MySprite DSP1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP1x, DSP1y), new Vector2(CircleSize, CircleSize) * 0.1f);
                MySprite DSP2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP2x, DSP2y), new Vector2(CircleSize, CircleSize) * 0.1f);

                DSM2Sprite.Color = CockpitFGColor.Alpha(1f);
                DSM1Sprite.Color = CockpitFGColor.Alpha(1f);
                DSCSprite.Color  = CockpitFGColor.Alpha(1f);
                DSP1Sprite.Color = CockpitFGColor.Alpha(1f);
                DSP2Sprite.Color = CockpitFGColor.Alpha(1f);

                Frame.Add(DSM2Sprite);
                Frame.Add(DSM1Sprite);
                Frame.Add(DSCSprite);
                Frame.Add(DSP1Sprite);
                Frame.Add(DSP2Sprite);


                // GlideSlope
                Vector2 GSCenter = new Vector2(Size.X * 1.3f, Center.Y);
                Vector2 GSM2     = new Vector2(GSCenter.X, GSCenter.Y - Size.Y * 0.4f);
                Vector2 GSM1     = new Vector2(GSCenter.X, GSCenter.Y - Size.Y * 0.2f);
                Vector2 GSP1     = new Vector2(GSCenter.X, GSCenter.Y + Size.Y * 0.2f);
                Vector2 GSP2     = new Vector2(GSCenter.X, GSCenter.Y + Size.Y * 0.4f);

                float   DeviationUnits = (float)ILSData.GlideSlopeDeviation / (float)GSFullScaleDeflectionAngle * Size.Y * 0.4f;
                Vector2 GSDiamondPos   = new Vector2(GSCenter.X, GSCenter.Y + DeviationUnits);


                MySprite GDSM2Sprite = MySprite.CreateSprite("Circle", GSM2, new Vector2(CircleSize, CircleSize) * 0.1f);
                MySprite GDSM1Sprite = MySprite.CreateSprite("Circle", GSM1, new Vector2(CircleSize, CircleSize) * 0.1f);
                MySprite GDSP1Sprite = MySprite.CreateSprite("Circle", GSP1, new Vector2(CircleSize, CircleSize) * 0.1f);
                MySprite GDSP2Sprite = MySprite.CreateSprite("Circle", GSP2, new Vector2(CircleSize, CircleSize) * 0.1f);

                MySprite GDSCSprite = MySprite.CreateSprite("SquareSimple", GSCenter, new Vector2(CircleSize * 0.2f, UnitY * 6));
                MySprite GSDiamond  = MySprite.CreateSprite("SquareSimple", GSDiamondPos, new Vector2(UnitX * 25, UnitY * 25));

                GDSCSprite.Color          = CockpitFGColor.Alpha(1f);
                GSDiamond.Color           = Color.LawnGreen.Alpha(1f);
                GSDiamond.RotationOrScale = ToRadian(45f);

                GDSM2Sprite.Color = CockpitFGColor.Alpha(1f);
                GDSM1Sprite.Color = CockpitFGColor.Alpha(1f);
                GDSP1Sprite.Color = CockpitFGColor.Alpha(1f);
                GDSP2Sprite.Color = CockpitFGColor.Alpha(1f);

                Frame.Add(GDSM2Sprite);
                Frame.Add(GDSM1Sprite);
                Frame.Add(GDSCSprite);
                Frame.Add(GDSP1Sprite);
                Frame.Add(GDSP2Sprite);

                Frame.Add(GSDiamond);

                // Re-center the center position.
                Center += CenterSub;
            }
コード例 #14
0
 public static void SetAlpha(this Color c, float a)
 {
     c.Alpha(a);
 }
コード例 #15
0
        public void DrawSprites(ref MySpriteDrawFrame frame, IMyTextSurface Surface)
        {
            Vector2 Size   = new Vector2(Surface.SurfaceSize.Y, Surface.SurfaceSize.Y);
            Vector2 Center = new Vector2(Surface.TextureSize.X / 2, Surface.TextureSize.Y / 2);
            float   UnitX  = Size.X / 256f;
            float   UnitY  = Size.Y / 256f;


            // Vars
            float CircleSize  = Size.Y * 0.95f;
            float ArrowLength = Size.Y * 0.8f;

            float ArrowRotation = rotation;
            float Deviation     = -5f; // between -12 and 12.


            Echo("BG: " + CockpitBGColor.ToString());
            Echo("FG: " + CockpitFGColor.ToString());


            // Set up the initial position - and remember to add our viewport offset
            // var position = new Vector2(128 * UnitX, 64 * UnitY) + _viewport.Position;

            // Circle
            MySprite Circle1 = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize));

            Circle1.Color = CockpitFGColor.Alpha(1f);
            frame.Add(Circle1);

            MySprite Circle2 = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize) * 0.95f);

            Circle2.Color = CockpitBGColor.Alpha(1f);
            frame.Add(Circle2);

            // Arrow
            MySprite ArrowBody = MySprite.CreateSprite("SquareSimple", Center, new Vector2(12 * UnitX, ArrowLength)); // new Vector2(10 * UnitX, 60 * UnitY)

            ArrowBody.Color           = CockpitFGColor.Alpha(1f);
            ArrowBody.RotationOrScale = ToRadian(ArrowRotation);
            frame.Add(ArrowBody);

            float AConstant = ArrowLength / 2.1f;
            float Ax        = (float)Math.Sin(ToRadian(ArrowRotation)) * AConstant;
            float Ay        = (float)Math.Cos(ToRadian(ArrowRotation)) * AConstant * -1;

            MySprite ArrowHead = MySprite.CreateSprite("Triangle", Center + new Vector2(Ax, Ay), Size * 0.2f);

            ArrowHead.Color           = CockpitFGColor.Alpha(1f);
            ArrowHead.RotationOrScale = ToRadian(ArrowRotation);
            frame.Add(ArrowHead);


            // Deviation bar
            float DConstant = Deviation / 12 * (Size.Y * 0.4f);
            float Dx        = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DConstant * -1;
            float Dy        = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DConstant;

            MySprite DeviationBar = MySprite.CreateSprite("SquareSimple", Center + new Vector2(Dx, Dy), new Vector2(12 * UnitX, ArrowLength / 3));

            DeviationBar.Color           = CockpitFGColor.Alpha(1f);
            DeviationBar.RotationOrScale = ToRadian(ArrowRotation);
            frame.Add(DeviationBar);



            // Deviation Scale
            float DSM2 = -1.0f * (Size.Y * 0.4f);
            float DSM1 = -0.5f * (Size.Y * 0.4f);
            float DSP1 = 0.5f * (Size.Y * 0.4f);
            float DSP2 = 1.0f * (Size.Y * 0.4f);

            Echo("DSM1: " + DSM1.ToString());
            Echo("DSM2: " + DSM2.ToString());
            Echo("DSP1: " + DSP1.ToString());
            Echo("DSP2: " + DSP2.ToString());

            float DSM2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM2 * -1;
            float DSM2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM2;

            float DSM1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSM1 * -1;
            float DSM1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSM1;

            float DSP1x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP1 * -1;
            float DSP1y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP1;

            float DSP2x = (float)Math.Sin(ToRadian(ArrowRotation + 90)) * DSP2 * -1;
            float DSP2y = (float)Math.Cos(ToRadian(ArrowRotation + 90)) * DSP2;

            MySprite DSM2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM2x, DSM2y), new Vector2(CircleSize, CircleSize) * 0.1f);
            MySprite DSM1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSM1x, DSM1y), new Vector2(CircleSize, CircleSize) * 0.1f);
            MySprite DSCSprite  = MySprite.CreateSprite("Circle", Center, new Vector2(CircleSize, CircleSize) * 0.1f);
            MySprite DSP1Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP1x, DSP1y), new Vector2(CircleSize, CircleSize) * 0.1f);
            MySprite DSP2Sprite = MySprite.CreateSprite("Circle", Center + new Vector2(DSP2x, DSP2y), new Vector2(CircleSize, CircleSize) * 0.1f);

            DSM2Sprite.Color = CockpitFGColor.Alpha(1f);
            DSM1Sprite.Color = CockpitFGColor.Alpha(1f);
            DSCSprite.Color  = CockpitFGColor.Alpha(1f);
            DSP1Sprite.Color = CockpitFGColor.Alpha(1f);
            DSP2Sprite.Color = CockpitFGColor.Alpha(1f);

            frame.Add(DSM2Sprite);
            frame.Add(DSM1Sprite);
            frame.Add(DSCSprite);
            frame.Add(DSP1Sprite);
            frame.Add(DSP2Sprite);
        }