Files
XCharts/Runtime/Internal/Helper/PolarHelper.cs
monitor1394 489095865d XCharts 2.0
2021-01-11 08:54:28 +08:00

34 lines
1.2 KiB
C#

/************************************************/
/* */
/* Copyright (c) 2018 - 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/************************************************/
using UnityEngine;
namespace XCharts
{
internal static class PolarHelper
{
internal static void UpdatePolarCenter(Polar polar, Vector3 chartPosition, float chartWidth, float chartHeight)
{
if (polar.center.Length < 2) return;
var centerX = polar.center[0] <= 1 ? chartWidth * polar.center[0] : polar.center[0];
var centerY = polar.center[1] <= 1 ? chartHeight * polar.center[1] : polar.center[1];
polar.runtimeCenterPos = chartPosition + new Vector3(centerX, centerY);
if (polar.radius <= 0)
{
polar.runtimeRadius = 0;
}
else if (polar.radius <= 1)
{
polar.runtimeRadius = Mathf.Min(chartWidth, chartHeight) * polar.radius;
}
else
{
polar.runtimeRadius = polar.radius;
}
}
}
}