Code Monkey home page Code Monkey logo

swift-noise's Introduction

noise
2.0

ci build status swift package index versions swift package index platforms

swift-noise is a free, pure Swift procedural noise generation library. The library product has no dependencies and does not import Foundation or any system frameworks.

All popular types of procedural noise are supported, including three gradient noises (often called Perlin or simplex noises), and two cellular noises (sometimes called Worley or Voronoi noises).

swift-noise includes a fractal brownian motion (FBM) noise composition framework, and a disk point sampler (often called a Poisson sampler), for generating visually even point distributions in the plane. swift-noise also includes pseudo-random number generation and hashing tools.

swift-noise’s entire public API is documented.

Building

Build Noise with the Swift Package Manager. Noise itself has no dependencies, but the tests use

The package includes an executable, generate-noise, that depends on swift-png. It generates noise locally for visual inspection. To regenerate example images, run the following command in the terminal:

swift run -c release generate-noise

swift-noise's People

Contributors

tayloraswift avatar heckj avatar

Stargazers

Josh Hrach avatar Patrick Sy avatar Alejandro Martínez avatar Eugene avatar Vinícius Chagas avatar Aron Cedercrantz avatar Semyon avatar nulldragon avatar Vladimir Leonidovich avatar tosaka avatar Marvin Nazari avatar Mike avatar Poseidon444 avatar fwcd avatar Eugen Pirogoff avatar Javi avatar Dmitriy avatar Marcus avatar Martin Dufort avatar Christoph Hagen avatar YR Chen avatar Sam Bishop avatar Jim Wallace avatar Morten Bek Ditlevsen avatar Pat Nakajima avatar 苹果API搬运工 avatar Shankeerthan avatar  avatar adamz avatar Go Takagi avatar Kotaro Suto avatar noppe avatar Akira MATSUDA avatar HongHao Zhang avatar David Kanenwisher avatar Adam Ferriss avatar Igor Kravchenko avatar Laszlo Teveli avatar Tibor Bödecs avatar Tim Kersey avatar Joannis Orlandos avatar Schultz Alexis avatar Tim Andersson avatar  avatar Daniel Eke avatar H4Master avatar Johan Sørensen avatar Johannes Ebeling avatar Kilian Koeltzsch avatar  avatar Brian Drelling avatar Florian Mari avatar Alex Sherbakov avatar Raja V avatar Manolis Pahlke avatar  avatar Yoshihiro Kato avatar Saqoosha avatar Karl avatar Greg Cotten avatar Alex Fringes avatar  avatar Andrew Winn avatar 1amageek avatar Matthew Fargo avatar Leon avatar Chris Slowik avatar  avatar Daniel Waylonis avatar Tiago Chaves avatar  avatar OK-MARCO avatar wwdc14yh avatar John Manos avatar  avatar Leonardo Kaminski Ferreira avatar Robert-Hein Hooijmans avatar Markus Winter avatar Todd Olsen avatar Shx Guo avatar Igor Zubkov avatar Reda Lemeden avatar Kangsoo Lee avatar Fahid Attique avatar Tyson Parks avatar Dan Cutting avatar  avatar Nealon Young avatar Kobi Kai Calev avatar Félix Fischer avatar Kevin avatar Astemir Eleev avatar Divgun avatar Alsey Coleman Miller avatar M. Czerniakowski avatar Emil Eriksson avatar Sebastian Buys avatar Chris avatar Oleg Ketrar avatar Josh Kopin avatar

Watchers

 avatar Martin Man avatar James Cloos avatar  avatar

swift-noise's Issues

“Fatal error: Array index is out of range” crash in `GradientNoise2D` `evaluate(_:Double,_:Double)`

I'm getting consistent “Fatal error: Array index is out of range” crashes in GradientNoise2D's evaluate(_ x:Double, _ y:Double) at gradient.swift on line 540.

The issue seems to be that the staticGradientNoise2D.points is initialized to have 32 members on line 354 , then when evaluate(…) is called, base_vertex_index:Int ends up with value of 32 (Int((2*sample_uv_rel.y - sample_uv_rel.x - Double(a))*0.5 + 1) << 4 with sample_uv_rel = (1, 0) & a = 0Int((2*1 - 0 - Double(0))*0.5 + 1) << 4Int(2*0.5 + 1) << 4Int(2) << 432, on line 457).

Finally on line 540, the code attempts to iterate in a for loop over GradientNoise2D.points[base_vertex_index ..< base_vertex_index + 4]… so GradientNoise2D.points[32..<36] when GradientNoise2D.points is only 32 elements long.

I don't really know how this noise math is meant to work, so I can't speculate as to what a fix should be other than… missing modulus? IDK.

revive this module

this module has fallen seriously out of maintenance, and needs to be revived

Generate noise as a dynamic background view in iOS

This is really not an issue but mostly an interrogation on my part.
I was wondering if I could generate dynamic noise background patterns and include them in my iOS app.

Questions:

  1. Would that be feasible as far as rendering time?
  2. Can I leverage the png creation capability of the tests and display the generated image directly in a view?
  3. Would it be possible to seed the noise generator to support a light and dark pattern to follow the iOS app environment (light or dark)?

Thanks

Strange crash with Fatal error: Array index is out of range

I get a crash somewhat randomly when generating in a loop of tens of thousands of pixels.

Here's an example of some of the settings when it crashed. It doesn't seem to crash particularly reproducibly.

let noise = GradientNoise2D(amplitude: 1, frequency: 0.5, seed: 332)
noise.evaluate(-25.3217883662071, 43.793)

I (amazingly) cannot figure out how to copy the stack trace out of Xcode but it crashes on this line:

https://github.com/kelvin13/noise/blob/965fc23d7e95fb21a9065ef1566ee2bbd2b86e4b/sources/noise/gradient.swift#L540

with

2022-02-04 12:49:07.312857-0800 Run[53616:517701] Swift/Array.swift:405: Fatal error: Array index is out of range

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.