mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
20 lines
946 B
C#
20 lines
946 B
C#
using UnityEngine;
|
|
|
|
namespace XCharts.Runtime
|
|
{
|
|
internal static class PolarHelper
|
|
{
|
|
public static void UpdatePolarCenter(PolarCoord 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];
|
|
var minWidth = Mathf.Min(chartWidth, chartHeight);
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |