Git Product home page Git Product logo

Comments (9)

Fennec-hub avatar Fennec-hub commented on June 11, 2024 1

Glad to be of help and thanks again for assembling this great library

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

The logic is correct:

  flipX() {
    this.transform({ rotate: [180, 0, 0] }); // first value corresponds to X
    return this;
  }
  flipX() {
    this.transform({ rotate: [0, 180, 0] }); // second value corresponds to Y
    return this;
  }

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

Great library by the way, I'm using it to create a small SVG path editor so big thanks.

Link it in.

from svg-path-commander.

Fennec-hub avatar Fennec-hub commented on June 11, 2024

If by flipping you mean rotating, then yes the logic is correct, but most people think of flipping as mirroring and you can see this behavior in a lot of graphic libraries like fabric.js, konva.js, three.js ... so the logic would be more of a reverse scale.

 flipX() {
    this.transform({ scale: [-1, 1, 1] }); 
    return this;
 }
 
 flipY() {
    this.transform({ scale: [1, -1, 1] }); 
    return this;
 }

Link it in.

It's part of an ongoing project, the SVG editor part will look more or less like this demo here ... I'll keep you in touch when the project is done.

from svg-path-commander.

Fennec-hub avatar Fennec-hub commented on June 11, 2024

I just noticed that the transform method don't handle all scale axis so in this case just inverting the two methods works fine.

  flipX() {
    this.transform({ rotate: [0, 180, 0] }); // Rotate the Y axes, mirror the X axes
    return this;
  }
  flipY() {
    this.transform({ rotate: [180, 0, 0] }); // Rotate the X axes, mirror the Y axes
    return this;
  }

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

I just noticed that the transform method don't handle all scale axis so in this case just inverting the two methods works fine.

Yes it does. Perhaps we have a bug?

from svg-path-commander.

Fennec-hub avatar Fennec-hub commented on June 11, 2024

Yes it does and it works ... please don't mind my last post.

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

@Fennec-hub you are right about flipX / flipY, our original source in SVGPath was like that and I changed it at some point.

I remember I was working with font-icons -> SVG icons and it didn't make sense to me I couldn't flip icons upside-down because I was confused on why flipX did not return the expected outcome.

I just checked the native DOMMatrix interface and it does exactly the same as you expected, so...

The future version will fix that.

from svg-path-commander.

thednp avatar thednp commented on June 11, 2024

@Fennec-hub please have a look at the latest master. Have fun

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.