public override Vector2 Point(double param) { var p12 = Arithmetic.Mix(_p[1], _p[2], param); return(Arithmetic.Mix(Arithmetic.Mix(Arithmetic.Mix(_p[0], _p[1], param), p12, param), Arithmetic.Mix(p12, Arithmetic.Mix(_p[2], _p[3], param), param), param)); }
public override void SplitInThirds(out EdgeSegment part1, out EdgeSegment part2, out EdgeSegment part3) { part1 = new QuadraticSegment(Color, _p[0], Arithmetic.Mix(_p[0], _p[1], 1.0 / 3.0), Point(1.0 / 3.0)); part2 = new QuadraticSegment(Color, Point(1.0 / 3.0), Arithmetic.Mix(Arithmetic.Mix(_p[0], _p[1], 5.0 / 9.0), Arithmetic.Mix(_p[1], _p[2], 4.0 / 9.0), 0.5), Point(2 / 3.0)); part3 = new QuadraticSegment(Color, Point(2.0 / 3.0), Arithmetic.Mix(_p[1], _p[2], 2.0 / 3.0), _p[2]); }
private static FloatRgb Mix(FloatRgb a, FloatRgb b, double weight) { var output = new FloatRgb { R = Arithmetic.Mix(a.R, b.R, weight), G = Arithmetic.Mix(a.G, b.G, weight), B = Arithmetic.Mix(a.B, b.B, weight) }; return(output); }
private static float Sample(Bitmap <float> bitmap, Vector2 pos) { int w = bitmap.Width, h = bitmap.Height; var x = pos.X * w - .5; var y = pos.Y * h - .5; var l = (int)Math.Floor(x); var b = (int)Math.Floor(y); var r = l + 1; var t = b + 1; var lr = x - l; var bt = y - b; l = Math.Clamp(l, 0, w - 1); r = Math.Clamp(r, 0, w - 1); b = Math.Clamp(b, 0, h - 1); t = Math.Clamp(t, 0, h - 1); return(Arithmetic.Mix(Arithmetic.Mix(bitmap[l, b], bitmap[r, b], lr), Arithmetic.Mix(bitmap[l, t], bitmap[r, t], lr), bt)); }
public override Vector2 Direction(double param) { var tangent = Arithmetic.Mix(Arithmetic.Mix(_p[1] - _p[0], _p[2] - _p[1], param), Arithmetic.Mix(_p[2] - _p[1], _p[3] - _p[2], param), param); if (!tangent) { if (param == 0) { return(_p[2] - _p[0]); } if (param == 1) { return(_p[3] - _p[1]); } } return(tangent); }
public override void SplitInThirds(out EdgeSegment part1, out EdgeSegment part2, out EdgeSegment part3) { part1 = new CubicSegment(Color, _p[0], _p[0] == _p[1] ? _p[0] : Arithmetic.Mix(_p[0], _p[1], 1.0 / 3.0), Arithmetic.Mix(Arithmetic.Mix(_p[0], _p[1], 1.0 / 3.0), Arithmetic.Mix(_p[1], _p[2], 1.0 / 3.0), 1.0 / 3.0), Point(1.0 / 3.0)); part2 = new CubicSegment(Color, Point(1.0 / 3.0), Arithmetic.Mix( Arithmetic.Mix(Arithmetic.Mix(_p[0], _p[1], 1.0 / 3.0), Arithmetic.Mix(_p[1], _p[2], 1.0 / 3.0), 1.0 / 3.0), Arithmetic.Mix(Arithmetic.Mix(_p[1], _p[2], 1.0 / 3.0), Arithmetic.Mix(_p[2], _p[3], 1.0 / 3.0), 1.0 / 3.0), 2.0 / 3.0), Arithmetic.Mix( Arithmetic.Mix(Arithmetic.Mix(_p[0], _p[1], 2.0 / 3.0), Arithmetic.Mix(_p[1], _p[2], 2.0 / 3.0), 2.0 / 3.0), Arithmetic.Mix(Arithmetic.Mix(_p[1], _p[2], 2.0 / 3.0), Arithmetic.Mix(_p[2], _p[3], 2.0 / 3.0), 2.0 / 3.0), 1.0 / 3.0), Point(2.0 / 3.0)); part3 = new CubicSegment(Color, Point(2.0 / 3.0), Arithmetic.Mix(Arithmetic.Mix(_p[1], _p[2], 2.0 / 3.0), Arithmetic.Mix(_p[2], _p[3], 2.0 / 3.0), 2.0 / 3.0), _p[2] == _p[3] ? _p[3] : Arithmetic.Mix(_p[2], _p[3], 2.0 / 3.0), _p[3]); }
public override Vector2 Direction(double param) { return(Arithmetic.Mix(_p[1] - _p[0], _p[2] - _p[1], param)); }
public override Vector2 Point(double param) { return(Arithmetic.Mix(Arithmetic.Mix(_p[0], _p[1], param), Arithmetic.Mix(_p[1], _p[2], param), param)); }