0

I am working on SVG-EDITOR for a long time now. I want to make the editor stack all objects drawn based on their fill properties on the fly(while i am editing). This would send all the objects with fill color: black to the back automatically.

Any ideas?

Basically i want all objects with color fill black to be sent to the back automatically after they are drawn. only black filled objects. any ideas on the coding?

nicholaswmin
  • 21,686
  • 15
  • 91
  • 167

1 Answers1

0

You should state which library you are using to create the SVG nodes or specify if you are not using any (you should probably use one to focus on your editor's specific features).

If you are creating the nodes yourself, you will need to reorganize them dynamically so that the objects you want to be down the stack end up before the others in the SVG DOM.

If it's javascript, you can do that with insertBefore for example, see this similar question with good answers.

If you are using Raphaƫl.js, you can use the .toBack() method on a created node. If you are using another library check if it has a similar function to send an item down the stack.

Since the shape is created as an editor feature, you should know if the color used is black or not and send to back accordingly.

Community
  • 1
  • 1
Joan Charmant
  • 2,012
  • 1
  • 18
  • 23