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


C# SVGGraphicsPath.GetBound方法代码示例

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


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

示例1: SetGradientVector

    private void SetGradientVector(SVGGraphicsPath graphicsPath)
    {
        Rect bound = graphicsPath.GetBound();
        if(_linearGradElement.x1.unitType == SVGLengthType.Percentage)
          _x1 = bound.x + (bound.width * _x1 / 100f);
        if(_linearGradElement.y1.unitType == SVGLengthType.Percentage)
          _y1 = bound.y + (bound.height * _y1 / 100f);
        if(_linearGradElement.x2.unitType == SVGLengthType.Percentage)
          _x2 = bound.x + (bound.width * _x2 / 100f);
        if(_linearGradElement.y2.unitType == SVGLengthType.Percentage)
          _y2 = bound.y + (bound.height * _y2 / 100f);

        if(_linearGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox) {
          Vector2 _point = graphicsPath.matrixTransform.Transform(new Vector2(_x1, _y1));
          _x1 = _point.x;
          _y1 = _point.y;

          _point = graphicsPath.matrixTransform.Transform(new Vector2(_x2, _y2));
          _x2 = _point.x;
          _y2 = _point.y;
        }
    }
开发者ID:MrJoy,项目名称:UnitySVG,代码行数:22,代码来源:SVGLinearGradientBrush.cs

示例2: SetGradientVector

    //-----
    private void SetGradientVector(SVGGraphicsPath graphicsPath)
    {
        Rect bound = graphicsPath.GetBound();

        if(_radialGradElement.cx.unitType == SVGLengthType.Percentage) {
          _cx = bound.x + (bound.width * _cx / 100f);
        }

        if(_radialGradElement.cy.unitType == SVGLengthType.Percentage) {
          _cy = bound.y + (bound.height * _cy / 100f);
        }

        if(_radialGradElement.r.unitType == SVGLengthType.Percentage) {
          Vector2 _p1 = new Vector2(bound.x, bound.y);
          Vector2 _p2 = new Vector2(bound.x + bound.width, bound.y + bound.height);
          _p1 = graphicsPath.matrixTransform.Transform(_p1);
          _p2 = graphicsPath.matrixTransform.Transform(_p2);

          float dd = (float)Math.Sqrt((_p2.x - _p1.x) * (_p2.x - _p1.x) + (_p2.y - _p1.y) * (_p2.y - _p1.y));
          _r = (dd * _r / 100f);
        }

        if(_radialGradElement.fx.unitType == SVGLengthType.Percentage) {
          _fx = bound.x + (bound.width * _fx / 100f);
        }
        if(_radialGradElement.fy.unitType == SVGLengthType.Percentage) {
          _fy = bound.y + (bound.height * _fy / 100f);
        }

        if((float)Math.Sqrt((_cx - _fx) * (_cx - _fx) + (_cy - _fy) * (_cy - _fy)) > _r) {
          Vector2 _cP = CrossPoint(_cx, _cy);
          _fx = _cP.x;
          _fy = _cP.y;
        }

        if(_radialGradElement.gradientUnits == SVGGradientUnit.ObjectBoundingBox) {
          Vector2 _point = new Vector2(_cx, _cy);
          _point = graphicsPath.matrixTransform.Transform(_point);
          _cx = _point.x;
          _cy = _point.y;

          _point = new Vector2(_fx, _fy);
          _point = graphicsPath.matrixTransform.Transform(_point);
          _fx = _point.x;
          _fy = _point.y;
        }
    }
开发者ID:nanuinteractive,项目名称:UnitySVG,代码行数:48,代码来源:SVGRadialGradientBrush.cs


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