当前位置: 首页>>代码示例>>C#>>正文


C# RectangleShape.GetLocalBounds方法代码示例

本文整理汇总了C#中SFML.Graphics.RectangleShape.GetLocalBounds方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleShape.GetLocalBounds方法的具体用法?C# RectangleShape.GetLocalBounds怎么用?C# RectangleShape.GetLocalBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SFML.Graphics.RectangleShape的用法示例。


在下文中一共展示了RectangleShape.GetLocalBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateDrawable

        protected override void UpdateDrawable() {
            base.UpdateDrawable();

            if (isCircle) {
                var circle = new SFML.Graphics.CircleShape(radius);
                circle.OutlineThickness = OutlineThickness;
                circle.OutlineColor = OutlineColor.SFMLColor;
                circle.FillColor = Color.SFMLColor;
                circle.SetPointCount((uint)CirclePointCount);
                SFMLDrawable = circle;
                Width = (int)circle.GetLocalBounds().Width;
                Height = (int)circle.GetLocalBounds().Height;
            }
            else {

                if (isShape) {
                    var rect = new SFML.Graphics.RectangleShape(new Vector2f(rectWidth, rectHeight));
                    rect.OutlineColor = OutlineColor.SFMLColor;
                    rect.OutlineThickness = OutlineThickness;
                    rect.FillColor = Color.SFMLColor;
                    SFMLDrawable = rect;
                    Width = (int)rect.GetLocalBounds().Width;
                    Height = (int)rect.GetLocalBounds().Height;
                }
                else {
                    SFMLVertices.Clear();

                    float x1, y1, x2, y2, u1, v1, u2, v2, cx1, cy1, cx2, cy2;

                    cx1 = ClippingRegion.Left;
                    cy1 = ClippingRegion.Top;
                    cx2 = ClippingRegion.Right;
                    cy2 = ClippingRegion.Bottom;

                    x1 = Util.Max(0, cx1);
                    u1 = TextureLeft + x1;

                    if (FlippedX) {
                        u1 = TextureRegion.Width - u1 + TextureLeft + TextureRegion.Left;
                    }

                    y1 = Util.Max(0, cy1);
                    v1 = TextureTop + y1;

                    if (FlippedY) {
                        v1 = TextureRegion.Height - v1 + TextureTop + TextureRegion.Top;
                    }

                    x2 = Util.Min(TextureRegion.Right, cx2);
                    u2 = TextureLeft + x2;

                    if (FlippedX) {
                        u2 = TextureRegion.Width - u2 + TextureLeft + TextureRegion.Left;
                    }

                    y2 = Util.Min(TextureRegion.Bottom, cy2);
                    v2 = TextureTop + y2;

                    if (FlippedY) {
                        v2 = TextureRegion.Height - v2 + TextureTop + TextureRegion.Top;
                    }

                    SFMLVertices.Append(x1, y1, Color, u1, v1);
                    SFMLVertices.Append(x1, y2, Color, u1, v2);
                    SFMLVertices.Append(x2, y2, Color, u2, v2);
                    SFMLVertices.Append(x2, y1, Color, u2, v1);
                }
            }
        }
开发者ID:KrissLaCross,项目名称:BreakOut,代码行数:69,代码来源:Image.cs


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