javascript - Ideal handle location for insertion of a new point in a bezier curve with Paper.js -


I have created a tool in paper.js that allows to insert new control points, which works great , Problem I is going on, it is that I should also calculate the handle position for each new control point (unless I am missing something, it seems that this paper does not do it for you), and This is proven to be a lot of work. The code below, which I am currently working with, handles the point successfully, though it distorts the curve. I handle this way that the curve is not distorted. gEditor.MoveTool.onMouseDown = function (event) {gEditor.HitResult = paper.project.hitTest (event.point, gEditor.HitOptions); Var location = gEditor.HitResult.location; Var newPoint = gEditor.HitResult.item.insert (location.index + 1, Event Page); Various Prections, Next Division; If (location.index - 1> = 0) {prevSegment = gEditor.HitResult.item.segments [location.index - 1]; } If (location.index + 2

Yes, paper.js already has this function: curve.divide () . After completing your hit test:

  path = HitResult.item; If (HitResult.type == 'stroke') {var location = HitResult.location; path.curves [location.index] .divide (location); }    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -