# New Library idea: Wave Function Collapse Pattern

**URL:** <https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016>\
**Category:** Summer of Code\
**Created:** [March 30, 2022, 7:31am UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016 "2022-03-30T07:31:20Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [March 30, 2022, 7:31am UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/1 "2022-03-30T07:31:20Z")

</div>

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/e/e052da89b3e03b9f7a02b583e0729e2505f3b10f.png)  
Hello, everyone! For GSOC 2022, I have an idea for a patterns library which could create all sorts of patterns from an input image following the tile model algorithm. Would like to hear if it is a valid proposal?

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [March 30, 2022, 2:18pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/2 "2022-03-30T14:18:22Z")

</div>

Cool idea! This library could be really nice to have and certainly counts as an [addon library](https://github.com/processing/processing/wiki/Project-List#-addon-library-development) proposal. I’m trying to imagine how you might complement built-in functions such as [image](https://p5js.org/reference/#/p5/image) and [texture](https://p5js.org/reference/#/p5/texture).

What are you thinking in terms of the API?

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [March 30, 2022, 7:53pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/3 "2022-03-30T19:53:16Z")

</div>

In terms of API I am thinking something like output\_img = pattern(img, size\_of\_pattern, width, height, [other options]). Now this output image could be drawn using the image function or filled as texture using texture function.

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [March 31, 2022, 8:32am UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/4 "2022-03-31T08:32:09Z")

</div>

Nice idea. [GitHub - allison-casey/wavefunctioncollapse](https://github.com/allison-casey/wavefunctioncollapse) may provide a starting point.

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [March 31, 2022, 7:20pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/5 "2022-03-31T19:20:36Z")

</div>

I’ll start working on the proposal and will update soon

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [April 3, 2022, 1:03pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/6 "2022-04-03T13:03:51Z")

</div>

@mcintyre @micycle I am ready with the first rough draft of my proposal for the library.  
[GSoC’22 Proposal](https://docs.google.com/document/d/1a-cydzd4z8BtOvinBPhR040JvLHS7fLjlM93qcdLBXk/edit?usp=sharing)  
Do read and add the comments in Google Docs wherever you feel it is required. And I would also like to get your opinion about the additional features mentioned in the proposal.

---

<div class="post-metadata">

**Author:** ![solub](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/solub/32/333_2.png) [@solub](https://discourse.processing.org/u/solub)\
**Post date:** [April 4, 2022, 12:48pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/7 "2022-04-04T12:48:18Z")

</div>

Processing implementation by @noahbuddy :

> **[GitHub - BitwiseSupernova/wave-function-collapse: Wave function collapse...](https://github.com/BitwiseSupernova/wave-function-collapse)**
>
> Wave function collapse implemented in Processing. Contribute to BitwiseSupernova/wave-function-collapse development by creating an account on GitHub.

[![](https://img.youtube.com/vi/THvTgZZEeOU/maxresdefault.jpg "Wave function collapse implemented in Processing") ](https://www.youtube.com/watch?v=THvTgZZEeOU)

One of the output images you are using in your document is actually based on this very imlementation. Also, I would suggest that you specify your sources (pictures you are using, authors of the algorithms you are mentionning):

- **[Maxim Gumin](https://github.com/mxgmn/WaveFunctionCollapse)** (author of the algorithm!)
- **[Marian42](https://marian42.de/article/wfc/)**
- **[Selfsame](https://selfsame.itch.io/unitywfc)**
- **[Anastasia Opara](https://www.anastasiaopara.com/texture-synthesis)**

The last images show the output from the algorithm invented by Anastasia Opara named MSTS (Multiresolution Stochastic Texture Synthesis - 2019). It is a better/improved version of the P.F. Harrisons’ algorithm (linked at the end of your document) as explained here:

[![](https://img.youtube.com/vi/fMbK7PYQux4/maxresdefault.jpg "More Like This, Please! Texture Synthesis and Remixing from a Single Example | Nordic Game 2019") ](https://www.youtube.com/watch?v=fMbK7PYQux4&t=1474s)

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [April 4, 2022, 2:05pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/8 "2022-04-04T14:05:50Z")

</div>

thanks @solub for these excellent resources!! I will surely mention all the image sources. 🙂

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [April 4, 2022, 5:58pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/9 "2022-04-04T17:58:25Z")

</div>

@mcintyre what project size and proposal title should I put for this proposal?

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 4, 2022, 8:58pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/10 "2022-04-04T20:58:18Z")

</div>

@anexas your proposal is off to a great start! I requested access to leave comments. In the meantime, have a look at proposals from students that I mentored in past summers.

> **[processing.pdf](https://drive.google.com/file/d/1zmskYhy6XkOxQCR2M5Lj7QGvnmvVH65r/view?usp=sharing)**
>
> Google Drive file.

> **[\[p5-teach.js\]-processing-GSoC](https://docs.google.com/document/d/1b1av_CQ7P21zzs1tMtzuQIT41R8x-iTqeOJh9j0oIMc/edit?usp=sharing)**
>
> GSoC’21 Proposal - Processing p5-teach.js Personal Details Name:​ Aditya Siddheshwar Course:​ B.Tech - Electronics and Communication Engineering University​: JK Institute of Applied Physics and Technology, Allahabad, India Email:​...

A few suggestions come to mind:

- Tell us about yourself!
- Provide a more detailed preview of the library’s API.
- Include multiple example sketches.
- We are not code snobs… but… `camelCase` is standard in JavaScript.
- Consider using [TDD](https://p5js.org/learn/tdd.html).
- Plan to document your code from the outset.
- Plan to write tutorials.
- Add a bit more detail to your proposed timeline.
- Incorporate @solub’s note about MSTS.
- Consider naming the library p5.texturesynth (following the pattern [here](https://p5js.org/libraries/)).

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [April 8, 2022, 9:21am UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/11 "2022-04-08T09:21:25Z")

</div>

> [@solub](#):
>
> The last images show the output from the algorithm invented by Anastasia Opara named MSTS (Multiresolution Stochastic Texture Synthesis - 2019).

Thanks @solub for sending this wonderful talk by Anastasia Opera.  
@mcintyre I have incorporated your suggestions into my proposal please take a look.

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 11, 2022, 1:57pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/12 "2022-04-11T13:57:14Z")

</div>

I added a few comments 👍🏽

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [April 12, 2022, 1:16pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/13 "2022-04-12T13:16:59Z")

</div>

@mcintyre I have made the requested changes, please take a look. Also what would be the project size according to you, 175h or 350h?

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [April 14, 2022, 3:24pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/14 "2022-04-14T15:24:39Z")

</div>

Your proposal is in great shape! I made another small suggestion in your example sketch.

It seems likely that you could deliver a useful library in 175h, but planning for 350h would guarantee time to work on those additional features. Personally, I’d love to play around with procedural texture generation and MSTS.

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [April 14, 2022, 7:24pm UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/15 "2022-04-14T19:24:52Z")

</div>

Thanks, I will try my best to deliver as many additional features as possible.

---

<div class="post-metadata">

**Author:** ![anexas](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/anexas/32/16016_2.png) [@anexas](https://discourse.processing.org/u/anexas)\
**Post date:** [April 16, 2022, 10:29am UTC](https://discourse.processing.org/t/new-library-idea-wave-function-collapse-pattern/36016/16 "2022-04-16T10:29:42Z")

</div>

![Screenshot_20220416-155832_Twitter](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/a/1/a1947bc5eaec701d45a97923c3b22b4f123437ad.jpeg)
