Skip to content

ynakajima/polyline2bezier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

polyline2bezier

Polyline to Bezier Curve

Demo

browser demo

Usage

var polyline = [
  [248,613],[246,598],[244,546],[245,514],
  [251,467],[254,449],[279,372],[287,357],
  [344,314],[384,303],[433,298],[581,319],
  [623,329],[677,356],[713,387],[742,425],
  [771,499],[777,542],[767,585],[740,633],
  [700,670],[675,684],[656,687],[620,693],
  [586,693],[532,673],[502,659],[487,653],
  [477,651],[476,650],[475,650]
];
var bezierCurves = polyline2bezier(polyline);
[
  [
    {"x":248,"y":613},
    {"x":241.20225126227012,"y":562.016884467026},
    {"x":239.23407781525805,"y":499.09866455537446},
    {"x":254,"y":449}
  ],
  [
    {"x":254,"y":449},
    {"x":261.6291758943156,"y":423.1152960728577},
    {"x":269.88879087681653,"y":397.40094664645085},
    {"x":279,"y":372}
  ],

  .
  .
 snip
  .
  .

  [
    {"x":532,"y":673},
    {"x":518.1170537031428,"y":667.3807122131768},
    {"x":492.2005260232342,"y":650},
    {"x":475,"y":650}
  ]
]

Credits

This code was ported from Philip J. Schneider's example implementation which was included in "Graphics Gems", Academic Press, 1990.