Git Product home page Git Product logo

Comments (8)

thednp avatar thednp commented on June 11, 2024

Not directly no. Currently we're rocking this function which only takes a transformObject so far.

I've explained before in great detail why only this implementation, but in short it's not worth your time to mess with that.

from svg-path-commander.

fabiospampinato avatar fabiospampinato commented on June 11, 2024

it's not worth your time to mess with that.

I'm not sure I have a choice unfortunately, I need to collapse an svg into a single path, but this svg could have groups applying matrix transformations to various parts of it, so I need to resolve those.

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

We might find an algorithm to merge paths into one, I'm sure, just I don't have the time right now.

However you can make use of the online demo to transform each path by its transform and/or its group transform, find a pattern and make an algorithm, I can try and help with that.

from svg-path-commander.

fabiospampinato avatar fabiospampinato commented on June 11, 2024

Thanks, for now I'm just using svg-path-commander, for it's ability to set the origin of a transformation, and svgpath, for its ability to apply a matrix transformation. Ideally I'd have just one dependency for manipulating paths, but it's good enough I guess.

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

If you only need to transfer the transformation from the transform attribute into the path commands, we only need a parser, then the algorithm is straight forward.

from svg-path-commander.

fabiospampinato avatar fabiospampinato commented on June 11, 2024

A parser for the value of the attribute? something like value.slice(7, -1).split(',').map(Number)? (assuming it's a matrix, but it should be simple enough to handle all the other options)

Could you point me to what the algorithm is? I've seen different ones, none worked with same as svgpath for me, maybe I'm missing something 🤔

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

In short, I'm thinking:

  • parse transform string from <path>s
  • parse transform string from parent <g> groups
  • apply the transformation to path in a specific order (I'm thinking parent groups first, EG parent G -> parent G -> path)
  • remove the transform attribute from all in the tree
  • repeat for every path

Does this sound complicated?

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

Closed due to no activity.

from svg-path-commander.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.