The Early Worm eats the Bird
Bitcoin Worms launched as a PFP collection Self-Inscribed by the community on 10/10/2023
Just a worm, just a Wiggle, now a Roadmap!
Bitcoin Worms are a collection of Worms on the blockchain. They stem from my childrens picture book named "WormE and the Wishing Tree"
The Bitcoin Worms stand on their own, but as a holder your Bitcoin Worm entitles you the owner to a PDF E-Book of the picture book and any other titles under "Bitcoin Worms"
Worm Generator
My worm maker will make you a 1 of 630,000 worm! The worm generator code provided ensures that it doesn't create duplicate worm images by using random selection from predefined arrays of backgrounds, bodies, eyes, mouths, and headgear.
Make yours for fun below Season 1 of Bitcoin Worms is closed :)
Inscribed imaged will not be indexed at this time!
.SVG Export generator beta testing (NO longer being indexed)
To see how it works scroll a little and press "generate" then save the scrambled looking file on your device, it will save as a browser link, right click and open in "notepad" and paste that code in the viewer to your right and you will see how your image file will be rendered on chain.
The generator is active by request but any inscriptions will NOT be currently indexed by BitcoinWorm™
Do not make any inscriptions, season 1 has ended, no more worms are being indexed, as was announced via Twitter during the free launch.
For more information or to ask questions please join our discord or follow us on Twitter.
@BitcoinWorms
This is where you can view .SVG or .HTML as an image as it will appear on chain.
This is WildTangs image tool, show them some love too.
https://recursive.wildtangz.com/
Below you will find a break down of how this is done, you can also view the BitcoinWorm generator on-chain at inscription 35221295 https://ord.io/35221295
Here's how it works:
Arrays of Options: The code defines arrays for each element of the worm image, such as backgrounds, bodies, eyes, mouths, and headgear. Each array contains multiple options or variations for that particular element.
Random Selection: When you click the "Generate Image" button, the code randomly selects an option from each of these arrays. For example, it randomly chooses a background, body, eye, mouth, and headgear from their respective arrays.
Composition: It then composes an image by layering these randomly selected elements on top of each other to create a unique worm image.
Display: The generated image is displayed in an SVG container on the web page.
If you refresh the page or leave the page and return, the code will start from scratch. When you click the "Generate Image" button again, it will repeat the random selection process. Therefore, each time you generate an image, it will be a new and random combination of elements, and there's no guarantee that you will see the same image again.
The generation of unique worm images is achieved by using a Set called generatedWorms to keep track of the combinations that have been generated. Here's how it works:
At the beginning of the script, an empty Set is created like this:
const generatedWorms = new Set();
This Set will be used to store the combinations of worm images that have been generated.
Generating Unique Worms: When the user clicks the "Generate Image" button, the generateImage function is called. Inside this function, it enters a loop that continues until a unique worm combination is found:
while (!uniqueWormFound) {
// ...
}
Inside this loop, random images are selected for each part of the worm (background, body, eye, mouth, headgear), and a combination string is created using these random images:
const wormCombination = `${randomBackground}-${randomBody}-${randomEye}-${randomMouth}-${randomHeadgear}`;
Checking for Uniqueness: Before adding the combination to the generatedWorms set, it checks whether this combination has already been generated:
if (!generatedWorms.has(wormCombination)) {
// This combination is unique
// Add it to the set
generatedWorms.add(wormCombination);
uniqueWormFound = true; // Exit the loop
// ...
}
If the combination has not been generated before, it's considered unique, added to the set, and the loop exits. If it has been generated before, the loop continues until a unique combination is found.
Keeping Track: The generatedWorms set keeps track of all unique combinations of worm images that have been generated during the user's session. It prevents duplicates by checking if a newly generated combination is already in the set.
Exporting Images: When the user clicks the "Export as SVG" button, the script will serialize the entire SVG container, including all the layers of the currently displayed worm images. It doesn't regenerate a new worm; instead, it exports the existing one that has been generated and displayed in the SVG container.
Persistence: The generatedWorms set persists as long as the user stays on the page. It holds the unique worm combinations in memory, allowing the code to ensure that the same combination isn't generated again during the same session.
So, essentially, the script keeps track of generated worm combinations using the Set data structure, ensuring that they are unique until the user leaves or refreshes the page.
The Bitcoin Worms were born from the Children's Book "WormE and the Wishing Tree" available on Amazon and some high street retailers, and a free E-Book for ALL holders, if interested please fill the form below.