Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Shapes with draw plugin #4

Open
rajkaran opened this issue Mar 13, 2019 · 2 comments
Open

Use Shapes with draw plugin #4

rajkaran opened this issue Mar 13, 2019 · 2 comments

Comments

@rajkaran
Copy link

How can I use shapes in conjunction with draw plugin. I want to draw a pentagon with mouse movement, similar to other basic shapes.

Is there a way to do it?

@Fuzzyma
Copy link
Member

Fuzzyma commented Mar 13, 2019

You can create a plugin for the draw plugin to handle other shapes. But for this to work, you would need to change the type of an element created by the shapes plugin. Usually, the type is the tag name. So a svg.js polygon object has the property type:polygon. The draw plugin picks that up and loads the polygon extension to draw a polygon. But thats not what you want. You want to draw a custom shape.
So, register an extension for say "star" and change the type of the created polygon to star so that draw loads the correct plugin. Now you can handle the drawing process.

oooor you just spawn a shape with a predefined size and make it resizable. That might be easier...

@rajkaran
Copy link
Author

I did tried to follow the discussion on issue svgdotjs/svg.draw.js#9

But couldn't make it work. I was trying to avoid reading source code, seems like i will have to do that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants