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


C# Rect.GetValueOrDefault方法代码示例

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


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

示例1: ObjectDetection

 /// <summary>
 /// 
 /// </summary>
 /// <param name="rect"></param>
 /// <param name="score"></param>
 /// <param name="classId"></param>
 public ObjectDetection(Rect? rect = null, float score = 0, int classId = -1)
 {
     Rect = rect.GetValueOrDefault(new Rect());
     Score = score;
     ClassId = classId;
 }
开发者ID:0sv,项目名称:opencvsharp,代码行数:12,代码来源:LatendSvmDetector.cs

示例2: InternalInitFromImage

    private void InternalInitFromImage(Texture2D texture, float pixelsPerMeter, string shaderType, RegistrationPoint regPoint, Rect? rect = null)
    {
        _texture = texture;
        _textureRect = rect.GetValueOrDefault(new Rect(0f, 0f, (float)_texture.width, (float)_texture.height));

        if (pixelsPerMeter == 0)
            pixelsPerMeter = CinchOptions.DefaultPixelsPerMeter;

        this._pixelsPerMeter = pixelsPerMeter;
        _regPoint = regPoint;

        //flip the y-axis
        if (CinchOptions.UseTopLeftSpriteSheetCoordinates)
        {
            var h = _textureRect.height;
            _textureRect.yMin = _texture.height - (_textureRect.yMin + _textureRect.height);
            _textureRect.height = h;
        }

        var scaledRect = new Rect(_textureRect.x/_texture.width, _textureRect.y/_texture.height, _textureRect.width/_texture.width, _textureRect.height/_texture.height);

        _originalMesh = new Mesh();
        _originalMesh.name = "Scripted_Plane_New_Mesh";
        var fullWidth = _textureRect.width / pixelsPerMeter;
        var fullHeight = _textureRect.height / pixelsPerMeter;
        var left = fullWidth * (0f-regPoint.X);
        var right = fullWidth * (1f-regPoint.X);
        var top = fullHeight * (0f-regPoint.Y);
        var bottom = fullHeight * (1f-regPoint.Y);
        var front = -.1f;
        var flt = new Vector3(left,  top, front);
        var frt = new Vector3(right, top, front);
        var frb = new Vector3(right, bottom, front);
        var flb = new Vector3(left,  bottom, front);

        _originalMesh.vertices = new Vector3[] {
                                    flt, frt, frb, flb
        };

        _originalMesh.uv = new Vector2[] {
            new Vector2 (scaledRect.xMin, scaledRect.yMin),
            new Vector2 (scaledRect.xMax, scaledRect.yMin),
            new Vector2 (scaledRect.xMax, scaledRect.yMax),
            new Vector2 (scaledRect.xMin, scaledRect.yMax)
        };

        _originalMesh.triangles = new int[] {
            3 , 2 , 1 , 0 , 3 , 1
        };
        _originalMesh.RecalculateNormals();

        _meshFilter = gameObject.AddComponent<MeshFilter>();
        _meshFilter.sharedMesh = _transformedMesh;

        var shader = ShaderCache.GetShader(shaderType);
        _meshRenderer = gameObject.AddComponent<MeshRenderer>();
        _meshRenderer.castShadows = false;
        _meshRenderer.receiveShadows = false;
        _material = _meshRenderer.material;
        _material.shader = shader;
        _material.mainTexture = _texture;
        _material.color = new Color( 1f, 1f, 1f, 1f );
        _material.mainTexture.wrapMode = TextureWrapMode.Clamp;

        if (Parent == null)
            _meshRenderer.enabled = false; //default it to false until it gets added

        __UpdateMesh();
    }
开发者ID:kyallbarrows,项目名称:Cinch_4-3,代码行数:69,代码来源:CinchSprite.cs


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