tayloraswift / swift-noise

Generate and compose commonly-used procedural noises and distributions, in pure Swift
https://swiftinit.org/docs/swift-noise/noise
Apache License 2.0
113 stars 11 forks source link

Generate noise as a dynamic background view in iOS #20

Open martindufort opened 1 month ago

martindufort commented 1 month ago

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

tayloraswift commented 1 month ago
  1. i don't know if the library can generate noise animations in real time, but one thing you could do is bake an animation of the noise to run in a loop. to make it seamless, i suggest sampling one of the three-dimensional noises in a ring-like motion. you’d have to implement a little bit of geometric math for that though.

  2. you could certainly use PNG, but i’m not an iOS expert and there might be a better file format for this.

  3. what i would recommend is to generate primary color channels, and then map each of those channels to a light or dark hue to customize the appearance.

martindufort commented 1 month ago

Thanks a bunch for this. I was unclear in my previous message but my initial goal was to display a single generated noise image as a background view.

However I will surely rethink this and possibly have some subtle motion / animations between various images.

Will play around with this and report back if I get stuck. Thanks.