using System.Collections.Generic;
using System.Linq;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Splines;
using UnityEngine.UIElements;
namespace Unity.Splines.Examples
{
///
/// This sample demonstrates how to create a spline from a collection of points drawn by the cursor.
///
public class Paint : MonoBehaviour
{
// The minimum amount of cursor movement to be considered a new sample.
const float StrokeDeltaThreshold = .1f;
const int LeftMouseButton = 0;
[SerializeField]
Mesh m_SampleDot;
[SerializeField]
Material m_SampleMat, m_ControlPointMat;
// Point reduction epsilon determines how aggressive the point reduction algorithm is when removing redundant
// points. Lower values result in more accurate spline representations of the original line, at the cost of
// greater number knots.
[Range(0f, 1f), SerializeField]
float m_PointReductionEpsilon = .15f;
// Tension affects how "curvy" splines are at knots. 0 is a sharp corner, 1 is maximum curvitude.
[Range(0f, 1f), SerializeField]
float m_SplineTension = 1 / 4f;
Label m_Stats;
Camera m_Camera;
List m_Stroke = new List(1024);
List m_Reduced = new List(512);
bool m_Painting;
Vector3 m_LastMousePosition;
void Start()
{
m_Camera = Camera.main;
m_Stats = PaintUI.root.Q