mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-23 17:30:10 +00:00
3.0 - unitypackage
This commit is contained in:
28
Runtime/Coord/Polar/PolarHelper.cs
Normal file
28
Runtime/Coord/Polar/PolarHelper.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts
|
||||
{
|
||||
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];
|
||||
polar.context.center = chartPosition + new Vector3(centerX, centerY);
|
||||
if (polar.radius <= 0)
|
||||
{
|
||||
polar.context.radius = 0;
|
||||
}
|
||||
else if (polar.radius <= 1)
|
||||
{
|
||||
polar.context.radius = Mathf.Min(chartWidth, chartHeight) * polar.radius;
|
||||
}
|
||||
else
|
||||
{
|
||||
polar.context.radius = polar.radius;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user