Thanks for the tip I think I managed to find the code I was looking for:
public sealed class LinearDiamond
: LinearStraight
{
public override float ComputeUnboundedLerp(int x, int y)
{
float dx = x - StartPoint.X;
float dy = y - StartPoint.Y;
float lerp1 = (dx * this.dtdx) + (dy * this.dtdy);
float lerp2 = (dx * this.dtdy) - (dy * this.dtdx);
float absLerp1 = Math.Abs(lerp1);
float absLerp2 = Math.Abs(lerp2);
return absLerp1 + absLerp2;
}
public override float BoundLerp(float t)
{
return Utility.Clamp(t, 0, 1);
}
public LinearDiamond(bool alphaOnly, BinaryPixelOp normalBlendOp)
: base(alphaOnly, normalBlendOp)
{
}
}
I was just wondering what was held in the variables "this.dtdx" and "this.dtdy". Although I can see the code I am not quite sure what it is doing:
protected float dtdx;
protected float dtdy;
public override void BeforeRender()
{
PointF vec = new PointF(EndPoint.X - StartPoint.X, EndPoint.Y - StartPoint.Y);
float mag = Utility.Magnitude(vec);
if (EndPoint.X == StartPoint.X)
{
this.dtdx = 0;
}
else
{
this.dtdx = vec.X / (mag * mag);
}
if (EndPoint.Y == StartPoint.Y)
{
this.dtdy = 0;
}
else
{
this.dtdy = vec.Y / (mag * mag);
}
base.BeforeRender();
}
What does "Utility.Magnitude(vec)" do?
Why do you do "this.dtdx = vec.X / (mag * mag)" when both end and start points are the same?
Thanks again