bezier creates a bezier curve between the begin and end points.
(begin, end vg.Point)
| 343 | |
| 344 | // bezier creates a bezier curve between the begin and end points. |
| 345 | func (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. |
| 365 | func (s *Sankey) DataRange() (xmin, xmax, ymin, ymax float64) { |