MCPcopy Index your code
hub / github.com/gonum/plot / bezier

Method bezier

plotter/sankey.go:345–362  ·  view source on GitHub ↗

bezier creates a bezier curve between the begin and end points.

(begin, end vg.Point)

Source from the content-addressed store, hash-verified

343
344// bezier creates a bezier curve between the begin and end points.
345func (s *Sankey) bezier(begin, end vg.Point) []vg.Point {
346 // directionOffsetFrac is the fraction of the distance between begin.X and
347 // end.X for the bezier control points.
348 const directionOffsetFrac = 0.3
349 inPts := []vg.Point{
350 begin,
351 {X: begin.X + (end.X-begin.X)*directionOffsetFrac, Y: begin.Y},
352 {X: begin.X + (end.X-begin.X)*(1-directionOffsetFrac), Y: end.Y},
353 end,
354 }
355 curve := bezier.New(inPts...)
356
357 // nPoints is the number of points for bezier interpolation.
358 const nPoints = 20
359 outPts := make([]vg.Point, nPoints)
360 curve.Curve(outPts)
361 return outPts
362}
363
364// DataRange implements the plot.DataRanger interface.
365func (s *Sankey) DataRange() (xmin, xmax, ymin, ymax float64) {

Callers 1

PlotMethod · 0.95

Calls 2

NewFunction · 0.92
CurveMethod · 0.80

Tested by

no test coverage detected