TMXGlueLib.TiledMapToShapeCollectionConverter.ConvertTmxObjectToFrbPolygonSave C# (CSharp) Метод

ConvertTmxObjectToFrbPolygonSave() приватный статический Метод

private static ConvertTmxObjectToFrbPolygonSave ( this tiledMapSave, string name, double x, double y, double w, double h, double rotation, mapObjectgroupObjectEllipse ellipse ) : PolygonSave
tiledMapSave this
name string
x double
y double
w double
h double
rotation double
ellipse mapObjectgroupObjectEllipse
Результат FlatRedBall.Content.Polygon.PolygonSave
        private static PolygonSave ConvertTmxObjectToFrbPolygonSave(this TiledMapSave tiledMapSave, string name, double x, double y, double w, double h, double rotation, mapObjectgroupObjectEllipse ellipse)
        {
            var pointsSb = new StringBuilder();

            if (ellipse == null)
            {
                pointsSb.Append("0,0");

                pointsSb.AppendFormat(" {0},{1}", w, 0);
                pointsSb.AppendFormat(" {0},{1}", w, h);
                pointsSb.AppendFormat(" {0},{1}", 0, h);
            }
            else
            {
                const double a = .5;
                const double b = .5;

                // x = a cos t
                // y = b cos t
                var first = true;
                string firstPoint = "";
                for (var angle = 0; angle <= 360; angle += 18)
                {
                    var radians = MathHelper.ToRadians(angle);

                    var newx = a*Math.Cos(radians)*w+w/2;
                    var newy = b*Math.Sin(radians)*h+h/2;
                    if (first)
                    {
                        firstPoint = string.Format("{0},{1}", newx, newy);
                    }
                    pointsSb.AppendFormat("{2}{0},{1}", newx, newy, first ? "" : " ");
                    first = false;
                }

                pointsSb.AppendFormat(" {0}", firstPoint);
            }

            return tiledMapSave.ConvertTmxObjectToFrbPolygonSave(name, x, y, rotation, pointsSb.ToString(), true);
        }

Same methods

TiledMapToShapeCollectionConverter::ConvertTmxObjectToFrbPolygonSave ( this tiledMapSave, string name, double x, double y, double rotation, string points, bool connectBackToStart ) : PolygonSave