Пример #1
0
        private static void DrawCompare(this SKCanvas canvas, SKImageInfo info, CelestialDrawModel origin, CelestialDrawModel compare)
        {
            var originRadius    = origin.Radius;
            var compareRadius   = compare.Radius;
            var maxCanvasWidth  = info.Width;
            var maxCanvasHeight = info.Height;
            var maxRadius       = DoubleHelper.GetMax(originRadius, compareRadius);
            var minRadius       = DoubleHelper.GetMin(originRadius, compareRadius);

            var divisionFactor = maxCanvasWidth * 0.9 / (minRadius * 4 > maxRadius ? 2 : 1);

            var factor = maxRadius / divisionFactor;

            var originFactoredRadius  = (int)DoubleHelper.GetMax(Math.Floor(originRadius / factor), 1);
            var compareFactoredRadius = (int)DoubleHelper.GetMax(Math.Floor(compareRadius / factor), 1);

            var originCentreX  = GetCentreX(maxCanvasWidth, originFactoredRadius, true);
            var compareCentreX = GetCentreX(maxCanvasWidth, compareFactoredRadius, false);

            var centreY = maxCanvasHeight / 2;

            var originDraw  = new CanvasDrawModel(origin.Id, origin.Description, originFactoredRadius, originCentreX, centreY, origin.Color, null, null, 0);
            var compareDraw = new CanvasDrawModel(compare.Id, compare.Description, compareFactoredRadius, compareCentreX, centreY, compare.Color, null, null, 0);

            canvas.Draw(originDraw);
            canvas.Draw(compareDraw);
        }
Пример #2
0
        private static int GetCentreX(int canvasWidth, int factoredRadius, bool lefthand)
        {
            var halfCanvasWidth = (int)DoubleHelper.GetMax((int)Math.Floor(canvasWidth * 0.5), 1);

            if (factoredRadius >= halfCanvasWidth)
            {
                return(lefthand
                    ? (int)Math.Floor(canvasWidth * 0.45) - factoredRadius
                    : (int)Math.Floor(canvasWidth * 0.55) + factoredRadius);
            }

            if (factoredRadius * 2 < halfCanvasWidth)
            {
                return(lefthand
                    ? (int)Math.Floor(canvasWidth * 0.25)
                    : (int)Math.Floor(canvasWidth * 0.75));
            }

            return(lefthand
                ? 0
                : canvasWidth);
        }
 public static double GetEllipticity(this ICalculatableRadius model) =>
 1 - (DoubleHelper.GetMin(model.EquatorialRadius, model.PolarRadius) / DoubleHelper.GetMax(model.EquatorialRadius, model.PolarRadius));