Giter VIP home page Giter VIP logo

Comments (8)

brendanzab avatar brendanzab commented on August 25, 2024

I like this. Any reason why you are using functions, not methods on Seed?

from noise-rs.

mpowell-imvu avatar mpowell-imvu commented on August 25, 2024

Because it hadn't occurred to me. :-)

My first draft didn't include Seed. Then I realized I needed a seed structure, so added it to all the functions. So I didn't think of turning them into member functions.

That said, I think making them into member functions would make them less composable. If I want to call brownian2d on perlin noise now, this is how I'd do it:

let noise = brownian2d(seed, point, perlin2d, 16, 3);

But if we made these member functions of Seed, it would have to be:

let noise = seed.brownian2d(point, |seed: Seed, point: (f32, f32)| seed.perlin2d(point), 16, 3);

So I think I'd argue to keep them as free functions. That said, Seed should really be passed by borrow. I'll go through and fix that.

Also, I left of lacunarity and persistence in the brownian motion, even though your current implementation includes them. They should probably be added back in. However, I also feel they should have defaults of 2.0 and 0.5, as that's what you want like 99% of the time.

from noise-rs.

mpowell-imvu avatar mpowell-imvu commented on August 25, 2024

Oh, apparently I can't edit the issue once it's been responded to. Oh well. The proposed changes are still captured in my comment.

Also thinking about a way to better generalize the worley noise into two parts. One generates a set of nearby cell points, and the other analyzes those points to produce a value. Sort of like what's already in this proposal, except with the ability to swap out for a different point generation algorithm.

I don't think I'd include any other point generation algorithms in the noise-rs library, for now... But I could see consumers of this library wanting to implement some alternate algorithms.

from noise-rs.

brendanzab avatar brendanzab commented on August 25, 2024

Regarding the composability concerns, note that UFCS you could do:

seed.brownian2d((x, y), Seed::perlin2d, ..)

Have you seen http://libnoise.sourceforge.net/ by the way? Here are some Haskell libraries based on it:

Might be abit complex though, I like the simplicity of your approach.

from noise-rs.

Cifram avatar Cifram commented on August 25, 2024

I had not seen this... I'll dig into it's structure a bit, and see if there's anything that seems worth pulling out.

from noise-rs.

Razaekel avatar Razaekel commented on August 25, 2024

@Cifram do you feel a need to expand on this any further?

from noise-rs.

Cifram avatar Cifram commented on August 25, 2024

No, not really... This post was made before I started contributing to this library. This API was pretty much implemented, and refined, before my attention turned elsewhere. I haven't been actively involved in any development here for close to 2 years.

from noise-rs.

Razaekel avatar Razaekel commented on August 25, 2024

Thanks for the followup.

from noise-rs.

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.