using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PCUT.Extensions.Transforms
{
    public abstract class SvgTransform
    {
        protected static readonly double DToRFactor = Math.PI / 180;
        protected SvgTransform _nextTransform { get; private set; }
        public void SetNext(SvgTransform nextTransform)
        {
            if (this != nextTransform)
                _nextTransform = nextTransform;
        }

        public (double X, double Y) Transform(double x, double y)
        {
            (x, y) = InternalTransform(x, y);
            if (_nextTransform != null)
                (x, y) = _nextTransform.Transform(x, y);

            return (x, y);
        }

        protected abstract (double X, double Y) InternalTransform(double x, double y);

        public static readonly SvgTransform Default = new DefaultTransform();
        private class DefaultTransform : SvgTransform
        {
            protected override (double X, double Y) InternalTransform(double x, double y)
            {
                return (x, y);
            }
        }
    }
}
