Files
XCharts/Runtime/Internal/Helper/PolarHelper.cs
2020-07-01 09:38:00 +08:00

34 lines
1.2 KiB
C#

/******************************************/
/* */
/* Copyright (c) 2018 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;
}
}
}
}