bezierjs icon indicating copy to clipboard operation
bezierjs copied to clipboard

Offset is drawing a line on both sides of a cubic curve?

Open llimllib opened this issue 9 years ago • 2 comments
trafficstars

Given this code:

var pts = [ 120, 79.63967819396663, 173.33333333333331, 118.72659522329167, 226.66666666666669, 109.84371034788978, 272, 85.57546366477419 ],
    curve = new Bezier(pts),
    ocurve = curve.offset(20);

draw_curve(curve, "line");
ocurve.forEach(function(c) {
  draw_curve(c, "offsetpath");
});

I get a properly offset line below curve, but also a bit of the curve offset by the same amount but above curve. Here is a demo.

Is this a bug, or am I misunderstanding how this is an expected behavior?

llimllib avatar Aug 16 '16 18:08 llimllib

This looks like a very curious bug. If I edit the coordinates in http://jsbin.com/vadayaneli/edit?html,console,output just a little, the offsetting works fine, so there is bound to be a rounding issue happening here.

Pomax avatar Aug 16 '16 22:08 Pomax

True! On firefox, 173.3333 does not reproduce the bug, but 173.33333 does. 226.66666 does, but 226.6666 doesn't

llimllib avatar Aug 17 '16 02:08 llimllib