Jump to content

4fingers

Newbies
  • Posts

    2
  • Joined

  • Last visited

4fingers's Achievements

Newbie

Newbie (1/14)

  • First Post
  • Conversation Starter
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. 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
  2. Hi, I was just wondering how the Conical and Diamond gradients were achieved. So far I have only been able to get a linear like gradient using something like this: gradient = sin(pos.x * Pi) I am just interested in the algorithm or pseudo code. I tried looking at the source but had no idea where to look. Any help would be great.
×
×
  • Create New...