Skip to content

Instantly share code, notes, and snippets.

@anabelle
Last active May 27, 2022 19:26
Show Gist options
  • Save anabelle/b9085908664f17dfee01431464bf977d to your computer and use it in GitHub Desktop.
Save anabelle/b9085908664f17dfee01431464bf977d to your computer and use it in GitHub Desktop.
454089
// Generates images from DNA - returns all of them in HTML
Tree.prototype.generateTreeImage = function(dna) {
var url = "https://studio.ethereum.org/static/img/cryptopizza/";
dna = dna.toString();
var basis = (dna.substring(0, 2) % 2) + 1;
var cheese = (dna.substring(2, 4) % 10) + 1;
var meat = (dna.substring(4, 6) % 18) + 1;
var spice = (dna.substring(6, 8) % 7) + 1;
var veggie = (dna.substring(8, 10) % 22) + 1;
var image = "";
image += '<img src="' + url + "basis/basis-" + basis + '.png"/>';
image += '<img src="' + url + "cheeses/cheese-" + cheese + '.png"/>';
image += '<img src="' + url + "meats/meat-" + meat + '.png"/>';
image += '<img src="' + url + "spices/spice-" + spice + '.png"/>';
image += '<img src="' + url + "veggies/veg-" + veggie + '.png"/>';
if (dna == 5142446803) {
image =
'<img src="https://studio.ethereum.org/static/img/cryptopizza/basis/basis-2.png"/>\
<img src="https://studio.ethereum.org/static/img/cryptopizza/meats/meat-13.png"/>\
<img src="https://studio.ethereum.org/static/img/cryptopizza/8fe918632d847e8ea3ebffbd47bd8ca9.png"/>';
}
return image;
};
<div class="ingredients">
<img src="https://studio.ethereum.org/static/img/cryptopizza/basis/basis-2.png">
<img src="https://studio.ethereum.org/static/img/cryptopizza/cheeses/cheese-1.png">
<img src="https://studio.ethereum.org/static/img/cryptopizza/meats/meat-17.png">
<img src="https://studio.ethereum.org/static/img/cryptopizza/spices/spice-3.png">
<img src="https://studio.ethereum.org/static/img/cryptopizza/veggies/veg-4.png">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment