Creating new path objects

What Wick Editor Version are you using?
1.19.3

Describe the Problem
What I want to do is create basically a new path object because I don’t exactly want to use the clone function because I don’t want unnecessary clips

What have you tried so far?
So far I have basically used console.log(this) and found that I should be able to use this code

this._parent._children[this._parent._children.length] = new this.view.paper.Path({
    segments: [[20, 20], [80, 80], [140, 20]],
    fillColor: 'black',
    closed: true
});

Its supposed to go to the parent of this which is the frame. Then it goes to the children of that frame to add a new object with the new this.view.paper.Path
When I play the project nothing happens, but if I open the outliner/hierarchy it just breaks the editor.

Do you have a Wick Editor File that we can see? Optional*
My Project10-15-2021_18-48-52.wick (1.6 KB)

You could use @Hamzah_Alani workaround…

I’m currently working in something similar…
You can benefit from it,

Here… WickPaths11-17-2021_22-40-32.wick (1.4 KB)

2 Likes

I’ll have to test it a bit more but it looks promising. I might be able to make a better custom clone system with this since it looks that I should be able to make send to back/front/forward functions that work.

The sky is the limit, but maybe some stars could be reached. :pray:

I’ve done some more testing and looked a bit at https://www.wickeditor.com/editor/corelibs/wick-engine/wickengine.js but adding objects with the frame.addPath() does not seem to allow for paper.js functions to be used. Although I will look a bit more into using some of the built-in wick functions.

At the moment I’ll probably be using my custom clone system because I recently found out that Send clip to front/back does work with a slight edit with my paths because for some reason when I used console.log() on the frame to see what its children were it didn’t display any of the objects that I added when they were actually there the whole time.

frame.addPath(Wick.Path) expects a Wick.Path which is a wrapper of paper path

Yeah the frame.addPath(Wick.Path) needs the Wick.Path which contains a paper path but at least in the example you gave if you use something like…

wp.view.item.translate([100,50]) // should move the object 100 on the x and 50 on the y

after adding the path to the frame it doesn’t move the path. Although the translate function might not be the most useful there are other functions that I might want to use

Simply use .x and .y properties

well that was just an example that the functions can’t be used. Translate isn’t that useful since there is an easy work around but there are other functions that could be useful like some interesting ones that I came across more recently getTangentAt(offset) and getNormalAt(offset) and others.

In the future we will be adding a lot of that stuff. But in theory a wick path has a paper inside… see inside the wick.path class, they use a function updateJson (i dont remember the exact name and im not in front of my pc right now) or something that apply the change to the paper path or item.

Well I thought that the WickPah._json only contains values, but I don’t know