80 lines
1.9 KiB
C#
80 lines
1.9 KiB
C#
using System;
|
|
namespace DALI.ToolKit
|
|
{
|
|
public struct DaliStrokePoint: ICloneable
|
|
{
|
|
public DaliStrokePoint(double x, double y)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
T = TimeSpan.MaxValue;
|
|
P = 0.5;
|
|
}
|
|
|
|
public DaliStrokePoint(double x, double y, TimeSpan t, double p)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
P = p;
|
|
T = t;
|
|
}
|
|
|
|
public bool IsCoordinatesOnly { get => T == TimeSpan.MaxValue && P == 0.5; }
|
|
|
|
public double X { get; set; }
|
|
public double Y { get; set; }
|
|
public double P { get; set; }
|
|
public TimeSpan T { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("[DaliStrokePoint: X={0}, Y={1}, P={2}, T={3}]", X, Y, P, T);
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (!(obj is DaliStrokePoint))
|
|
return false;
|
|
|
|
DaliStrokePoint ds = (DaliStrokePoint)obj;
|
|
|
|
double epsylon = 0.01;
|
|
|
|
var diffX = Math.Abs(ds.X - this.X);
|
|
var diffY = Math.Abs(ds.Y - this.Y);
|
|
|
|
if (diffX < epsylon && diffY < epsylon)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public bool EqualsEpsylon(DaliStrokePoint ds, double epsylon)
|
|
{
|
|
var diffX = Math.Abs(ds.X - this.X);
|
|
var diffY = Math.Abs(ds.Y - this.Y);
|
|
|
|
if (diffX < epsylon && diffY < epsylon)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return this.GetHashCode();
|
|
}
|
|
|
|
public object Clone()
|
|
{
|
|
return this.MemberwiseClone();
|
|
}
|
|
}
|
|
|
|
|
|
}
|