waywardRJ / hashlips_art_engine

HashLips Art Engine is a tool used to create multiple different instances of artworks based on provided layers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Welcome to HashLips 👄

All the code in these repos was created and explained by HashLips on the main YouTube channel.

To find out more please visit:

📺 YouTube

💬 Telegram

🐦 Twitter

ℹ️ Website

HashLips Art Engine 🔥

Create generative art by using the canvas api and node js. Before you use the generation engine, make sure you have node.js and yarn installed.

Installation 🛠️

If you are cloning the project then run this first, otherwise you can download the source code on the release page and skip this step.

git clone https://github.com/HashLips/hashlips_art_engine.git

Go to the root of your folder and run this command if you have yarn installed.

yarn install

Alternatively you can run this command if you have node installed.

npm install

Usage ℹ️

Create your different layers as folders in the 'layers' directory, and add all the layer assets in these directories. You can name the assets anything as long as it has a rarity weight attached in the file name like so: example element#70.png. You can optionally change the delimiter # to anything you would like to use in the variable rarityDelimiter in the src/config.js file.

Once you have all your layers, go into src/config.js and update the layerConfigurations objects layersOrder array to be your layer folders name in order of the back layer to the front layer.

Example: If you were creating a portrait design, you might have a background, then a head, a mouth, eyes, eyewear, and then headwear, so your layersOrder would look something like this:

const layerConfigurations = [
  {
    growEditionSizeTo: 100,
    layersOrder: [
      { name: "Head" },
      { name: "Mouth" },
      { name: "Eyes" },
      { name: "Eyeswear" },
      { name: "Headwear" },
    ],
  },
];

The name of each layer object represents the name of the folder (in /layers/) that the images reside in.

Optionally you can now add multiple different layerConfigurations to your collection. Each configuration can be unique and have different layer orders, use the same layers or introduce new ones. This gives the artist flexibility when it comes to fine tuning their collections to their needs.

Example: If you were creating a portrait design, you might have a background, then a head, a mouth, eyes, eyewear, and then headwear and you want to create a new race or just simple re-order the layers or even introduce new layers, then you're layerConfigurations and layersOrder would look something like this:

const layerConfigurations = [
  {
    // Creates up to 50 artworks
    growEditionSizeTo: 50,
    layersOrder: [
      { name: "Background" },
      { name: "Head" },
      { name: "Mouth" },
      { name: "Eyes" },
      { name: "Eyeswear" },
      { name: "Headwear" },
    ],
  },
  {
    // Creates an additional 100 artworks
    growEditionSizeTo: 150,
    layersOrder: [
      { name: "Background" },
      { name: "Head" },
      { name: "Eyes" },
      { name: "Mouth" },
      { name: "Eyeswear" },
      { name: "Headwear" },
      { name: "AlienHeadwear" },
    ],
  },
];

Then optionally, update your format size, ie the outputted image size, and the growEditionSizeTo on each layerConfigurations object, which is the amount of variation outputted.

When you are all ready, run the following command and your outputted art will be in the build directory:

npm run build

or

node index.js

The program will output all the images in the build directory along with the metadata files. Each collection will have a _metadata.json file that consists of all the metadata in the collection inside the build folder. The build folder also will contain all the images as well as single json files that represent each image file. The single json file of a image will look something like this:

{
  "dna": "d956cdf4e460508b5ff90c21974124f68d6edc34",
  "name": "#1",
  "description": "This is the description of your NFT project",
  "image": "https://hashlips/nft/1.png",
  "edition": 1,
  "date": 1731990799975,
  "attributes": [
    { "trait_type": "Background", "value": "Black" },
    { "trait_type": "Eyeball", "value": "Red" },
    { "trait_type": "Eye color", "value": "Yellow" },
    { "trait_type": "Iris", "value": "Small" },
    { "trait_type": "Shine", "value": "Shapes" },
    { "trait_type": "Bottom lid", "value": "Low" },
    { "trait_type": "Top lid", "value": "Middle" }
  ],
  "compiler": "HashLips Art Engine"
}

That's it, you're done. Hope you create some awesome artworks with this code 👄.

About

HashLips Art Engine is a tool used to create multiple different instances of artworks based on provided layers.

License:MIT License


Languages

Language:JavaScript 100.0%