You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You provide a way to extend components or to change controllers behavior but there is no way to extend Shape (RectangleShape, PolygonShape etc..) since we can't override the dataToShape function used in the ShapeManager.
I fixed it by adding public shapeFactory: { dataToShape : ((s: ShapeData) => Shape) } = { dataToShape : dataToShape };
as a property in the ShapeManager class
and then, by changing the two const obj = dataToShape(s);
to const obj = this.shapeFactory.dataToShape(s);
in the constructor of ShapeManager (line 530 and 553 of /packages/graphics-2d/src/shapes-manager.ts)
These 3 changes make me able to set my own dataToShape method when I extend pixano webcomponents. this.shManager.shapeFactory.dataToShape = myOwnDataToShape;
Do you think you can make this kind of changes so we will be able to extend Shapes ?
Hi @bpioge
it is a great idea to expose the dataToShape function, thanks ! Is there a particular reason why you suggest a shapeFactory property ? If not, we can directly use a dataToShape member function in ShapesManager that can be changed into your own conversion function:
public dataToShape: ((s: ShapeData) => Shape) = dataToShape;
Then use:
this.shManager.dataToShape = myOwnDataToShape;
In any case, this is a small change and can be done/published within the week
@bpioge I closed the issue, thanks again ! don't hesitate to open a new one if you have other suggestions to simplify customization of shapes in terms of usage
Activity
camilledupont commentedon Jul 29, 2020
Hi @bpioge
it is a great idea to expose the dataToShape function, thanks ! Is there a particular reason why you suggest a shapeFactory property ? If not, we can directly use a dataToShape member function in ShapesManager that can be changed into your own conversion function:
Then use:
In any case, this is a small change and can be done/published within the week
bpioge commentedon Jul 29, 2020
Yes sure, you're right. I was probably doing some tests, i don't know why I did it :-)
bpioge commentedon Jul 29, 2020
Thank you !
camilledupont commentedon Jul 30, 2020
Ok ! I'll probably push/publish tomorrow :)
camilledupont commentedon Jul 31, 2020
@bpioge I closed the issue, thanks again ! don't hesitate to open a new one if you have other suggestions to simplify customization of shapes in terms of usage
Fix pixano#2
Merge branch 'cuboid' into 'master'
Release V0.3.4 - Fix pixano#2