2020-07-01 09:38:00 +08:00
|
|
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-02-19 22:37:57 +08:00
|
|
|
namespace XCharts.Runtime
|
2020-07-01 09:38:00 +08:00
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
internal static class PolarHelper
|
2020-07-01 09:38:00 +08:00
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
public static void UpdatePolarCenter(PolarCoord polar, Vector3 chartPosition, float chartWidth, float chartHeight)
|
2020-07-01 09:38:00 +08:00
|
|
|
{
|
|
|
|
|
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];
|
2021-11-23 13:20:07 +08:00
|
|
|
polar.context.center = chartPosition + new Vector3(centerX, centerY);
|
2020-07-01 09:38:00 +08:00
|
|
|
if (polar.radius <= 0)
|
|
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
polar.context.radius = 0;
|
2020-07-01 09:38:00 +08:00
|
|
|
}
|
|
|
|
|
else if (polar.radius <= 1)
|
|
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
polar.context.radius = Mathf.Min(chartWidth, chartHeight) * polar.radius;
|
2020-07-01 09:38:00 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-11-23 13:20:07 +08:00
|
|
|
polar.context.radius = polar.radius;
|
2020-07-01 09:38:00 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|