Can't edit Wick.Path in frame of creation

Bug4-8-2022_17-21-26.wick (1.6 KB)

Example project ^

The issue is when you create a Wick.Path you can’t edit it’s contained paper.Path through WICKPATH.view.item. Annoying because it means that you have to wait a frame before changing values.

If you console.log() a value that you changed but didn’t look like it changed it does look like the value does change but it doesn’t seem to get registered by the Wick.Path.

I think this bug may affect things like Wick.Clip as well because Jovanny has mentioned of a bug with subclips when cloning as well.

1 Like

Hi @SomeoneElse, I saw your code and attempt of repositioning the created path object.

I don’t know if there’s an easier method for this, but I just created a new function for repositioning a path object:

project.position=function(path,posXY){
    var diffX = posXY[0]-path.view.item.position.x;
    var diffY = posXY[1]-path.view.item.position.y;
    var NewSegments = path.json[1].segments;
    path.json[1].segments.forEach(function(value,index){
        NewSegments[index][0]=[value[0][0]+diffX,value[0][1]+diffY]; 
    });
    var A={
        "applyMatrix": path.json[1].applyMatrix,
        "segments": NewSegments,
        "closed": path.json[1].closed,
        "fillColor": path.fillColor,
        "strokeColor": path.strokeColor,
        "strokeCap": path.json[1].strokeCap
    };
    path.json=["Path",A];
};

After adding this function to your project something like

project.position(path,[0,0]);

should be able to reposition a path object to points (0,0)

Here’s an example where the created path object follows your cursor:
Bug4-10-2022_9-27-37.wick (1.9 KB)

This works by adding the difference in position to the segment points of the path object’s data. The json data was completely redefined in the function, which gives you a chance to adjust other variables along the way. Consider this as a workaround. Let me know if you’re confused or curios about anything else :+1:

1 Like

@SomeoneElse, for cloning, I think that I figured while back that the engine uses an asyncronic waiting method, and it needs that 1 frame to complete the operation of copying all objects recursively.

Currently I can get around this issue by not creating the Wick.Path immediately but rather applying the transformations I need and then creating the Wick.Path which works for I need.

1 Like