• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# VRageMath.Rectangle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VRageMath.Rectangle的典型用法代码示例。如果您正苦于以下问题:C# Rectangle类的具体用法?C# Rectangle怎么用?C# Rectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Rectangle类属于VRageMath命名空间,在下文中一共展示了Rectangle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

        internal void Draw(Rectangle rect, Color color, MyVideoRectangleFitMode fitMode)
        {
            int w = 0, h = 0;
            byte [] data = m_wrapper.GetTextureData(ref w, ref h);
            process_frame(data, w, h);

            Rectangle dst = rect;
            Rectangle src = new Rectangle(0, 0, w, h);
            var videoSize = new Vector2(w, h);
            float videoAspect = videoSize.X / videoSize.Y;
            float rectAspect = (float)rect.Width / (float)rect.Height;

            // Automatic decision based on ratios.
            if (fitMode == MyVideoRectangleFitMode.AutoFit)
                fitMode = (videoAspect > rectAspect) ? MyVideoRectangleFitMode.FitHeight : MyVideoRectangleFitMode.FitWidth;

            float scaleRatio = 0.0f;
            switch (fitMode)
            {
                case MyVideoRectangleFitMode.None:
                    break;

                case MyVideoRectangleFitMode.FitWidth:
                    scaleRatio = (float)dst.Width / videoSize.X;
                    dst.Height = (int)(scaleRatio * videoSize.Y);
                    if (dst.Height > rect.Height)
                    {
                        var diff = dst.Height - rect.Height;
                        dst.Height = rect.Height;
                        diff = (int)(diff / scaleRatio);
                        src.Y += (int)(diff * 0.5f);
                        src.Height -= diff;
                    }
                    break;

                case MyVideoRectangleFitMode.FitHeight:
                    scaleRatio = (float)dst.Height / videoSize.Y;
                    dst.Width = (int)(scaleRatio * videoSize.X);
                    if (dst.Width > rect.Width)
                    {
                        var diff = dst.Width - rect.Width;
                        dst.Width = rect.Width;
                        diff = (int)(diff / scaleRatio);
                        src.X += (int)(diff * 0.5f);
                        src.Width -= diff;
                    }
                    break;
            }
            dst.X = rect.Left + (rect.Width - dst.Width) / 2;
            dst.Y = rect.Top + (rect.Height - dst.Height) / 2;


            VRageMath.RectangleF destination = new VRageMath.RectangleF(dst.X, dst.Y, dst.Width, -dst.Height);
            VRageMath.Rectangle? source = src;
            Vector2 origin = new Vector2(src.Width / 2 * 0, src.Height);

            MySpritesRenderer.AddSingleSprite(m_texture, videoSize, color, origin, Vector2.UnitX, source, destination);
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:58,代码来源:MyVideoPlayer.cs


示例2: DrawSprite

        public static void DrawSprite(string texture, ref RectangleF destination, bool scaleDestination, ref Rectangle? sourceRectangle, Color color, float rotation, Vector2 rightVector, ref Vector2 origin, SpriteEffects effects, float depth, bool waitTillLoaded = true, string targetTexture = null)
        {
            var message = MessagePool.Get<MyRenderMessageDrawSprite>(MyRenderMessageEnum.DrawSprite);

            message.Texture = texture;
            message.DestinationRectangle = destination;
            message.SourceRectangle = sourceRectangle;
            message.Color = color;
            message.Rotation = rotation;
            message.RightVector = rightVector;
            message.Depth = depth;
            message.Effects = effects;
            message.Origin = origin;
            message.ScaleDestination = scaleDestination;
            message.WaitTillLoaded = waitTillLoaded;
            message.TargetTexture = targetTexture;

            EnqueueMessage(message);
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:19,代码来源:MyRenderProxy.cs


示例3: DrawVideo

        static void DrawVideo(uint id, Rectangle rect, Color color, MyVideoRectangleFitMode fitMode)
        {
            MyVideoPlayerDx9 video;
            if (m_videos.TryGetValue(id, out video))
            {
                Rectangle dst = rect;
                Rectangle src = new Rectangle(0, 0, video.VideoWidth, video.VideoHeight);
                var videoSize = new Vector2(video.VideoWidth, video.VideoHeight);
                float videoAspect = videoSize.X / videoSize.Y;
                float rectAspect = (float)rect.Width / (float)rect.Height;

                // Automatic decision based on ratios.
                if (fitMode == MyVideoRectangleFitMode.AutoFit)
                    fitMode = (videoAspect > rectAspect) ? MyVideoRectangleFitMode.FitHeight : MyVideoRectangleFitMode.FitWidth;

                float scaleRatio = 0.0f;
                switch (fitMode)
                {
                    case MyVideoRectangleFitMode.None:
                        break;

                    case MyVideoRectangleFitMode.FitWidth:
                        scaleRatio = (float)dst.Width / videoSize.X;
                        dst.Height = (int)(scaleRatio * videoSize.Y);
                        if (dst.Height > rect.Height)
                        {
                            var diff = dst.Height - rect.Height;
                            dst.Height = rect.Height;
                            diff = (int)(diff / scaleRatio);
                            src.Y += (int)(diff * 0.5f);
                            src.Height -= diff;
                        }
                        break;

                    case MyVideoRectangleFitMode.FitHeight:
                        scaleRatio = (float)dst.Height / videoSize.Y;
                        dst.Width = (int)(scaleRatio * videoSize.X);
                        if (dst.Width > rect.Width)
                        {
                            var diff = dst.Width - rect.Width;
                            dst.Width = rect.Width;
                            diff = (int)(diff / scaleRatio);
                            src.X += (int)(diff * 0.5f);
                            src.Width -= diff;
                        }
                        break;
                }
                dst.X = rect.Left + (rect.Width - dst.Width) / 2;
                dst.Y = rect.Top + (rect.Height - dst.Height) / 2;

                Texture texture = video.OutputFrame;

                // Draw upside down
                VRageMath.RectangleF destination = new VRageMath.RectangleF(dst.X, dst.Y, dst.Width, -dst.Height);
                VRageMath.Rectangle? source = src;
                Vector2 origin = new Vector2(src.Width / 2 * 0, src.Height);
                MyRender.DrawSprite(texture, null, ref destination, false, ref source, color, Vector2.UnitX, ref origin, VRageRender.Graphics.SpriteEffects.None, 0f);
            }
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:59,代码来源:MyRender-Video.cs


示例4: SpriteScissorPush

 public static void SpriteScissorPush(Rectangle screenRectangle)
 {
     var message = MessagePool.Get<MyRenderMessageSpriteScissorPush>(MyRenderMessageEnum.SpriteScissorPush);
     message.ScreenRectangle = screenRectangle;
     EnqueueMessage(message);
 }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:6,代码来源:MyRenderProxy.cs


示例5: UsingScissorRectangle

 public static SpriteScissorToken UsingScissorRectangle(ref RectangleF normalizedRectangle)
 {
     Vector2 screenSize     = GetScreenSizeFromNormalizedSize(normalizedRectangle.Size);
     Vector2 screenPosition = GetScreenCoordinateFromNormalizedCoordinate(normalizedRectangle.Position);
     var screenRectangle = new Rectangle((int)Math.Round(screenPosition.X, MidpointRounding.AwayFromZero),
                                         (int)Math.Round(screenPosition.Y, MidpointRounding.AwayFromZero),
                                         (int)Math.Round(screenSize.X, MidpointRounding.AwayFromZero),
                                         (int)Math.Round(screenSize.Y, MidpointRounding.AwayFromZero));
     VRageRender.MyRenderProxy.SpriteScissorPush(screenRectangle);
     return new SpriteScissorToken();
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:11,代码来源:MyGuiManager.cs


示例6: GetSafeAspectRatioPictureSize

        //  Return picture size that is safe for displaying in bounding area and doesn't distort the aspect ratio of original picture or bounding area.
        //  Example: picture of video frame is scaled to size of screen, so it fits it as much as possible, but still maintains aspect ration of
        //  original video frame or screen. So if screen's heigh is not enouch, video frame is scaled down to fit height, but also width is scaled
        //  according to original video frame.
        //  It's used whenever we need to scale picture/texture to some area, usually to screen size.
        //  Also this method calculated left/top coordinates, so it's always centered.
        static void GetSafeAspectRatioPictureSize(Vector2I originalSize, Rectangle boundingArea, out Rectangle outRect)
        {
            outRect.Width = boundingArea.Width;
            outRect.Height = (int)(((float)outRect.Width / (float)originalSize.X) * originalSize.Y);

            if (outRect.Height > boundingArea.Height)
            {
                outRect.Height = boundingArea.Height;
                outRect.Width = (int)(outRect.Height * ((float)originalSize.X / (float)originalSize.Y));
            }

            outRect.X = boundingArea.Left + (boundingArea.Width - outRect.Width) / 2;
            outRect.Y = boundingArea.Top + (boundingArea.Height - outRect.Height) / 2;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:20,代码来源:MyGuiManager.cs


示例7: GetSafeAspectRatioFullScreenPictureSize

 public static void GetSafeAspectRatioFullScreenPictureSize(Vector2I originalSize, out Rectangle outRect)
 {
     GetSafeAspectRatioPictureSize(originalSize, m_safeFullscreenRectangle, out outRect);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:4,代码来源:MyGuiManager.cs


示例8: DrawSpriteBatch

        /// <summary>Draws sprite batch at specified position</summary>
        /// <param name="normalizedCoord">X and Y are within interval [0,1]</param>
        /// <param name="normalizedSize">size of destination rectangle (normalized).
        /// Don't forget that it may be distorted by aspect ration, so rectangle size
        /// [1,1] can make larger wide than height on your screen.</param>
        /// <param name="useFullClientArea">True uses full client rectangle. False limits to GUI rectangle</param>
        public static void DrawSpriteBatch(string texture, Vector2 normalizedCoord, Vector2 normalizedSize, Color color, MyGuiDrawAlignEnum drawAlign, bool useFullClientArea = false, bool waitTillLoaded = true)
        {
            if (string.IsNullOrEmpty(texture))
                return;

            Vector2 screenCoord = GetScreenCoordinateFromNormalizedCoordinate(normalizedCoord, useFullClientArea);
            Vector2 screenSize = GetScreenSizeFromNormalizedSize(normalizedSize, useFullClientArea);
            screenCoord = MyUtils.GetCoordAligned(screenCoord, screenSize, drawAlign);

            var rect = new Rectangle((int)screenCoord.X, (int)screenCoord.Y, (int)screenSize.X, (int)screenSize.Y);

            DrawSprite(texture, rect, color, waitTillLoaded);
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:19,代码来源:MyGuiManager.cs


示例9: DrawSprite

 static void DrawSprite(string texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, float scale, VRageRender.Graphics.SpriteEffects effects, float layerDepth)
 {
     var destination = new RectangleF(position.X, position.Y, scale, scale);
     DrawSprite(texture, ref destination, true, ref sourceRectangle, color, rotation, ref origin, effects, layerDepth);
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:5,代码来源:MyGuiManager.cs


示例10: DrawSpriteBatch

 //  Draws sprite batch at specified SCREEN position (in screen coordinates, not normalized coordinates).
 public static void DrawSpriteBatch(string texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, float scale, VRageRender.Graphics.SpriteEffects effects, float layerDepth)
 {
     DrawSprite(texture, position, sourceRectangle, color, rotation, origin, scale, effects, layerDepth);
 }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:5,代码来源:MyGuiManager.cs


示例11: DrawVideo

        static void DrawVideo(uint id, Rectangle rect, Color color, MyVideoRectangleFitMode fitMode)
		{
            Debug.Assert(false);
		}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:4,代码来源:MyRender-Video.cs


示例12: DrawSprite

 static void DrawSprite(string texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth, bool waitTillLoaded = true)
 {
     var destination = new RectangleF(position.X, position.Y, scale, scale);
     DrawSprite(texture, ref destination, true, ref sourceRectangle, color, rotation, ref origin, effects, layerDepth, waitTillLoaded);
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MyGuiManager.cs


示例13: ProcessDrawMessage

        private static void ProcessDrawMessage(MyRenderMessageBase drawMessage)
        {
            switch (drawMessage.MessageType)
            {
                case MyRenderMessageEnum.SpriteScissorPush:
                    {
                        var msg = drawMessage as MyRenderMessageSpriteScissorPush;

                        MySpritesRenderer.ScissorStackPush(msg.ScreenRectangle);

                        break;
                    }

                case MyRenderMessageEnum.SpriteScissorPop:
                    {
                        MySpritesRenderer.ScissorStackPop();

                        break;
                    }

                case MyRenderMessageEnum.DrawSprite:
                    {
                        MyRenderMessageDrawSprite sprite = (MyRenderMessageDrawSprite)drawMessage;

                        MyFileTextureManager texManager = MyManagers.FileTextures;
                        MySpritesRenderer.AddSingleSprite(texManager.GetTexture(sprite.Texture, MyFileTextureEnum.GUI, waitTillLoaded: sprite.WaitTillLoaded), sprite.Color, sprite.Origin, sprite.RightVector, sprite.SourceRectangle, sprite.DestinationRectangle);

                        break;
                    }

                case MyRenderMessageEnum.DrawSpriteNormalized:
                    {
                        MyRenderMessageDrawSpriteNormalized sprite = (MyRenderMessageDrawSpriteNormalized)drawMessage;

                        var rotation = sprite.Rotation;
                        if (sprite.RotationSpeed != 0)
                        {
                            rotation += sprite.RotationSpeed * (float)(MyRender11.CurrentDrawTime - MyRender11.CurrentUpdateTime).Seconds;
                        }

                        Vector2 rightVector = rotation != 0f ? new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation)) : sprite.RightVector;

                        int safeGuiSizeY = MyRender11.ResolutionI.Y;
                        int safeGuiSizeX = (int)(safeGuiSizeY * 1.3333f);     //  This will mantain same aspect ratio for GUI elements

                        var safeGuiRectangle = new VRageMath.Rectangle(MyRender11.ResolutionI.X / 2 - safeGuiSizeX / 2, 0, safeGuiSizeX, safeGuiSizeY);
                        var safeScreenScale = (float)safeGuiSizeY / MyRenderGuiConstants.REFERENCE_SCREEN_HEIGHT;
                        float fixedScale = sprite.Scale * safeScreenScale;


                        var tex = MyManagers.FileTextures.GetTexture(sprite.Texture, MyFileTextureEnum.GUI, true);

                        var normalizedCoord = sprite.NormalizedCoord;
                        var screenCoord = new Vector2(safeGuiRectangle.Left + safeGuiRectangle.Width * normalizedCoord.X,
                            safeGuiRectangle.Top + safeGuiRectangle.Height * normalizedCoord.Y);

                        Vector2 sizeInPixels = tex.Size;
                        var sizeInPixelsScaled = sizeInPixels * fixedScale;

                        Vector2 alignedScreenCoord = screenCoord;
                        var drawAlign = sprite.DrawAlign;

                        if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
                        {
                            //  Nothing to do as position is already at this point
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
                        {
                            //  Move position to the texture center
                            alignedScreenCoord -= sizeInPixelsScaled / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X / 2.0f;
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM)
                        {
                            alignedScreenCoord -= sizeInPixelsScaled;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)
                        {
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X;
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM)
                        {
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y;// *0.75f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X;
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:101,代码来源:MyRender-Draw.cs


示例14: DrawVideo

 public static void DrawVideo(uint id, Rectangle rect, Color color)
 {
     DrawVideo(id, rect, color, MyVideoRectangleFitMode.None);
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:4,代码来源:MyRenderProxy.cs


示例15: GetSafeHeightPictureSize

 //  This method scales picture to bounding area according to bounding area's height. We don't care about width, so sometimes if picture has wide
 //  aspect ratio, borders of image may be outisde of the bounding area. This method is used when we want to have picture covering whole screen
 //  and don't care if part of picture is invisible. Also, aspect ration is unchanged too.
 static void GetSafeHeightPictureSize(Vector2I originalSize, Rectangle boundingArea, out Rectangle outRect)
 {
     outRect.Height = boundingArea.Height;
     outRect.Width = (int)(((float)outRect.Height / (float)originalSize.Y) * originalSize.X);
     outRect.X = boundingArea.Left + (boundingArea.Width - outRect.Width) / 2;
     outRect.Y = boundingArea.Top + (boundingArea.Height - outRect.Height) / 2;
 }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:10,代码来源:MyGuiManager.cs


示例16: SpriteScissorPush

 public static void SpriteScissorPush(Rectangle screenRectangle, string targetTexture = null)
 {
     var message = MessagePool.Get<MyRenderMessageSpriteScissorPush>(MyRenderMessageEnum.SpriteScissorPush);
     message.ScreenRectangle = screenRectangle;
     message.TargetTexture = targetTexture;
     EnqueueMessage(message);
 }
开发者ID:rem02,项目名称:SpaceEngineers,代码行数:7,代码来源:MyRenderProxy.cs


示例17: UpdateScreenSize

        public static void UpdateScreenSize(Vector2I screenSize, Vector2I screenSizeHalf, bool isTriple)
        {
            int safeGuiSizeY = screenSize.Y;
            int safeGuiSizeX = (int)(safeGuiSizeY * MyGuiConstants.SAFE_ASPECT_RATIO);     //  This will mantain same aspect ratio for GUI elements

            int safeFullscreenSizeX = screenSize.X;
            int safeFullscreenSizeY = screenSize.Y;

            m_fullscreenRectangle = new Rectangle(0, 0, screenSize.X, screenSize.Y);

            //  Triple head is drawn on three monitors, so we will draw GUI only on the middle one

            if (isTriple == true)
            {
                const int TRIPLE_SUB_SCREENS_COUNT = 3;
                //safeGuiSizeX = safeGuiSizeX / TRIPLE_SUB_SCREENS_COUNT;
                safeFullscreenSizeX = safeFullscreenSizeX / TRIPLE_SUB_SCREENS_COUNT;
            }


            m_safeGuiRectangle = new Rectangle(screenSize.X / 2 - safeGuiSizeX / 2, 0, safeGuiSizeX, safeGuiSizeY);

            //if (MyVideoModeManager.IsTripleHead() == true)
            //m_safeGuiRectangle.X += MySandboxGame.ScreenSize.X / 3;

            m_safeFullscreenRectangle = new Rectangle(screenSize.X / 2 - safeFullscreenSizeX / 2, 0, safeFullscreenSizeX, safeFullscreenSizeY);

            //  This will help as maintain scale/ratio of images, texts during in different resolution
            m_safeScreenScale = (float)safeGuiSizeY / MyGuiConstants.REFERENCE_SCREEN_HEIGHT;

            //  Min and max mouse coords (in normalized units). Must be calculated from fullscreen, no GUI rectangle.
            m_minMouseCoord = GetNormalizedCoordinateFromScreenCoordinate(new Vector2(m_safeFullscreenRectangle.Left, m_safeFullscreenRectangle.Top));
            m_maxMouseCoord = GetNormalizedCoordinateFromScreenCoordinate(new Vector2(m_safeFullscreenRectangle.Left + m_safeFullscreenRectangle.Width, m_safeFullscreenRectangle.Top + m_safeFullscreenRectangle.Height));
            m_minMouseCoordFullscreenHud = GetNormalizedCoordinateFromScreenCoordinate(new Vector2(m_fullscreenRectangle.Left, m_fullscreenRectangle.Top));
            m_maxMouseCoordFullscreenHud = GetNormalizedCoordinateFromScreenCoordinate(new Vector2(m_fullscreenRectangle.Left + m_fullscreenRectangle.Width, m_fullscreenRectangle.Top + m_fullscreenRectangle.Height));

#if XB1
            //XB1_TODO: error: 'VRage.Input.IMyInput' does not contain a definition for 'SetMouseLimits'
            //XB1_TODO: MyInput.Static.SetMouseLimits( new Vector2(m_safeFullscreenRectangle.Left, m_safeFullscreenRectangle.Top),
            //XB1_TODO:    new Vector2(m_safeFullscreenRectangle.Left + m_safeFullscreenRectangle.Width, m_safeFullscreenRectangle.Top + m_safeFullscreenRectangle.Height) );
#endif

            //  Normalized coordinates where width is always 1.0 and height something like 0.8
            //  Don't confuse with GUI normalized coordinates. They are different.
            //  HUD - get normalized screen size -> width is always 1.0, but height depends on aspect ratio, so usualy it is 0.8 or something.
            m_hudSize = CalculateHudSize();
            m_hudSizeHalf = m_hudSize / 2.0f;
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:48,代码来源:MyGuiManager.cs


示例18: DrawVideo

        public static void DrawVideo(uint id, Rectangle rect, Color color, MyVideoRectangleFitMode fitMode = MyVideoRectangleFitMode.None)
        {
            var message = MessagePool.Get<MyRenderMessageDrawVideo>(MyRenderMessageEnum.DrawVideo);

            message.ID = id;
            message.Rectangle = rect;
            message.Color = color;
            message.FitMode = fitMode;

            EnqueueMessage(message);
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:11,代码来源:MyRenderProxy.cs


示例19: DrawSprite

        public static void DrawSprite(string texture, ref RectangleF destination, bool scaleDestination, ref Rectangle? sourceRectangle, Color color, float rotation, Vector2 rightVector, ref Vector2 origin, SpriteEffects effects, float depth, bool waitTillLoaded = true)
        {
            Debug.Assert(!string.IsNullOrEmpty(texture) && (texture.EndsWith(".jpg") || texture.EndsWith(".dds") || texture.EndsWith(".png")), "Unsupported sprite texture! ");

            var message = MessagePool.Get<MyRenderMessageDrawSprite>(MyRenderMessageEnum.DrawSprite);

            message.Texture = texture;
            message.DestinationRectangle = destination;
            message.SourceRectangle = sourceRectangle;
            message.Color = color;
            message.Rotation = rotation;
            message.RightVector = rightVector;
            message.Depth = depth;
            message.Effects = effects;
            message.Origin = origin;
            message.ScaleDestination = scaleDestination;
            message.WaitTillLoaded = waitTillLoaded;

            EnqueueMessage(message);
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:20,代码来源:MyRenderProxy.cs


示例20: ProcessDrawMessage

        private static void ProcessDrawMessage(MyRenderMessageBase drawMessage)
        {
            switch (drawMessage.MessageType)
            {
                case MyRenderMessageEnum.SpriteScissorPush:
                    {
                        var msg = drawMessage as MyRenderMessageSpriteScissorPush;

                        MySpritesRenderer.ScissorStackPush(msg.ScreenRectangle);

                        break;
                    }

                case MyRenderMessageEnum.SpriteScissorPop:
                    {
                        MySpritesRenderer.ScissorStackPop();

                        break;
                    }

                case MyRenderMessageEnum.DrawSprite:
                    {
                        MyRenderMessageDrawSprite sprite = (MyRenderMessageDrawSprite)drawMessage;

                        MySpritesRenderer.AddSingleSprite(MyTextures.GetTexture(sprite.Texture, MyTextureEnum.GUI, waitTillLoaded: sprite.WaitTillLoaded), sprite.Color, sprite.Origin, sprite.RightVector, sprite.SourceRectangle, sprite.DestinationRectangle);

                        break;
                    }

                case MyRenderMessageEnum.DrawSpriteNormalized:
                    {
                        MyRenderMessageDrawSpriteNormalized sprite = (MyRenderMessageDrawSpriteNormalized)drawMessage;

                        var rotation = sprite.Rotation;
                        if (sprite.RotationSpeed != 0)
                        {
                            rotation += sprite.RotationSpeed * (float)(MyRender11.CurrentDrawTime - MyRender11.CurrentUpdateTime).Seconds;
                        }

                        Vector2 rightVector = rotation != 0f ? new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation)) : sprite.RightVector;

                        int safeGuiSizeY = MyRender11.ResolutionI.Y;
                        int safeGuiSizeX = (int)(safeGuiSizeY * 1.3333f);     //  This will mantain same aspect ratio for GUI elements

                        var safeGuiRectangle = new VRageMath.Rectangle(MyRender11.ResolutionI.X / 2 - safeGuiSizeX / 2, 0, safeGuiSizeX, safeGuiSizeY);
                        var safeScreenScale = (float)safeGuiSizeY / MyRenderGuiConstants.REFERENCE_SCREEN_HEIGHT;
                        float fixedScale = sprite.Scale * safeScreenScale;

                        var tex = MyTextures.GetTexture(sprite.Texture, MyTextureEnum.GUI, true);

                        var normalizedCoord = sprite.NormalizedCoord;
                        var screenCoord = new Vector2(safeGuiRectangle.Left + safeGuiRectangle.Width * normalizedCoord.X,
                            safeGuiRectangle.Top + safeGuiRectangle.Height * normalizedCoord.Y);

                        var sizeInPixels = MyTextures.GetSize(tex);
                        var sizeInPixelsScaled = sizeInPixels * fixedScale;

                        Vector2 alignedScreenCoord = screenCoord;
                        var drawAlign = sprite.DrawAlign;

                        if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP)
                        {
                            //  Nothing to do as position is already at this point
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER)
                        {
                            //  Move position to the texture center
                            alignedScreenCoord -= sizeInPixelsScaled / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_TOP)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_BOTTOM)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X / 2.0f;
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_BOTTOM)
                        {
                            alignedScreenCoord -= sizeInPixelsScaled;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)
                        {
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X;
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y / 2.0f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM)
                        {
                            alignedScreenCoord.Y -= sizeInPixelsScaled.Y;// *0.75f;
                        }
                        else if (drawAlign == MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_TOP)
                        {
                            alignedScreenCoord.X -= sizeInPixelsScaled.X;
                        }

//.........这里部分代码省略.........
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:101,代码来源:MyRender-Draw.cs



注:本文中的VRageMath.Rectangle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VRageMath.Vector2类代码示例发布时间:2022-05-26
下一篇:
C# VRageMath.MyBlockOrientation类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap