Git Product home page Git Product logo

Comments (8)

Chlumsky avatar Chlumsky commented on July 20, 2024

Thank you for reporting this. I think I fixed it just now.

from msdfgen.

Cultrarius avatar Cultrarius commented on July 20, 2024

Thank you for the quick response!

The shape is rendered correctly now, but only if I use the generateMSDF_legacy function; if I use the new generateMSDF function it creates just a black output.

from msdfgen.

Chlumsky avatar Chlumsky commented on July 20, 2024

Please link the exact input where this happens. The one you posted earlier behaves correctly for me.

from msdfgen.

Cultrarius avatar Cultrarius commented on July 20, 2024

I parsed the svg myself into cubic segments and did not use the SVG importer from your project, so maybe that is why it works for you.
This is the test case for the above teardrop shape (I hardcoded the edge values):

Shape dfShape;
Contour &contour = dfShape.addContour();
contour.addEdge(new CubicSegment(Point2(258.599060, 396.484863), Point2(269.933899, 386.063660), Point2(410.555725, 323.508911), Point2(117.682785, 187.383301)));
contour.addEdge(new CubicSegment(Point2(117.682785, 187.383301), Point2(117.682785, 187.383301), Point2(199.505142, 441.436646), Point2(258.599060, 396.484863)));
contour.addEdge(new CubicSegment(Point2(258.599060, 396.484863), Point2(258.599060, 396.484863), Point2(258.599060, 396.484863), Point2(258.599060, 396.484863)));

Vector2 scale(1, 1);
Vector2 translate(0, 0);
edgeColoringSimple(dfShape, 1, 0);
Bitmap<FloatRGB> msdfOutput(512, 512);

// this works fine
generateMSDF_legacy(msdfOutput, dfShape, 5, scale, translate);

// this just fills msdfOutput with -infinity for all values 
generateMSDF(msdfOutput, dfShape, 5, scale, translate);

from msdfgen.

Chlumsky avatar Chlumsky commented on July 20, 2024

In the code you posted, the last edge segment has the exact same value for all points. My program won't be able to deal with such an edge, because it for example needs to compute the direction of edges at their endpoints. I would argue this qualifies as invalid input, but maybe I should be trying to identify and remove these during shape normalization (which you didn't call anyway).

from msdfgen.

Cultrarius avatar Cultrarius commented on July 20, 2024

Interesting, thanks. I thought that maybe the last edge was a problem.

I would suggest not removing it during normalization (unless you would replace it with a working equivalent), but to check for such a case in the validate() method. I could open a pull request if you want to.

from msdfgen.

Chlumsky avatar Chlumsky commented on July 20, 2024

The thing is that we are dealing with floating point numbers, so more often than not, they might not be exactly equal, but maybe differ by a tiny fraction, and then I can't detect it. I can't just reject any vertices that seem "too close", because it could be intentional. That's why I think it should be up to the caller to provide a valid input.

from msdfgen.

Cultrarius avatar Cultrarius commented on July 20, 2024

That's why I think it should be up to the caller to provide a valid input.

Exactly, but your validate() method should reflect that - if the input is valid or not.

And it is in my opinion absolutely OK to reject vertices in the same edge that are closer than a very small delta (which can also be zero), as such input usually only leads to problems with later calculations and rounding errors.

from msdfgen.

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.