Files
XCharts/Runtime/Coord/Polar/PolarHelper.cs

20 lines
946 B
C#
Raw Normal View History

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];
var minWidth = Mathf.Min(chartWidth, chartHeight);
2021-11-23 13:20:07 +08:00
polar.context.center = chartPosition + new Vector3(centerX, centerY);
polar.context.insideRadius = polar.radius[0] <= 1 ? minWidth * polar.radius[0] : polar.radius[0];
polar.context.outsideRadius = polar.radius[1] <= 1 ? minWidth * polar.radius[1] : polar.radius[1];
polar.context.radius = polar.context.outsideRadius - polar.context.insideRadius;
2020-07-01 09:38:00 +08:00
}
}
}