### Install Jazzicon with npm Source: https://github.com/danfinlay/jazzicon/blob/master/README.md Use npm to install the Jazzicon library as a dependency. ```bash npm install jazzicon -S ``` -------------------------------- ### Generate Jazzicons in JavaScript Source: https://github.com/danfinlay/jazzicon/blob/master/README.md Import the jazzicon function and use it to generate multiple identicons with random seeds, appending them to the document body. Requires the jazzicon library to be installed. ```javascript var jazzicon = require('jazzicon') var body = document.querySelector('body') for(var i = 0; i < 60; i++) { var el = jazzicon(100, Math.round(Math.random() * 10000000)) body.appendChild(el) } ``` -------------------------------- ### Jazzicon - addressGen Function Source: https://context7.com/danfinlay/jazzicon/llms.txt Utility function that generates a random Ethereum-style address string. Useful for testing and demonstration purposes. ```APIDOC ## addressGen() ### Description Generates a random Ethereum-style address string (e.g., '0x3f8a2c1d9e'). Useful for testing and demonstration purposes. ### Method JavaScript Function ### Parameters None ### Request Example ```javascript var addressGen = require('./addressGen'); // Generate a random address for testing var randomAddress = addressGen(); console.log(randomAddress); // Use generated address as seed for identicon var jazzicon = require('jazzicon'); var address = addressGen(); var seed = parseInt(address.slice(2), 16); var icon = jazzicon(100, seed); document.body.appendChild(icon); ``` ### Response #### Success Response (String) - A string representing a randomly generated Ethereum-style address. #### Response Example ```json "0x3f8a2c1d9e" ``` ``` -------------------------------- ### Generate Jazzicon Identicons Source: https://context7.com/danfinlay/jazzicon/llms.txt Use the main generateIdenticon function to create a DOM element for an identicon. Specify the pixel diameter and an integer seed for deterministic results. This function is commonly used for user avatars, converting wallet addresses to seeds for consistent visuals. ```javascript var jazzicon = require('jazzicon'); // Generate a single identicon with 100px diameter and specific seed var icon = jazzicon(100, 12345678); document.body.appendChild(icon); ``` ```javascript // Generate identicon from a wallet address (convert hex to integer) var walletAddress = '0x1234567890abcdef'; var seed = parseInt(walletAddress.slice(2, 10), 16); var walletIcon = jazzicon(48, seed); document.querySelector('.user-avatar').appendChild(walletIcon); ``` ```javascript // Generate multiple identicons in a loop var container = document.getElementById('user-list'); var userIds = [1001, 1002, 1003, 1004, 1005]; userIds.forEach(function(userId) { var el = jazzicon(64, userId); el.style.margin = '5px'; container.appendChild(el); }); ``` -------------------------------- ### Jazzicon - generateIdenticon Function Source: https://context7.com/danfinlay/jazzicon/llms.txt The main function exported by the library that generates a complete identicon as a DOM element. It takes a pixel diameter for sizing and an integer seed for deterministic generation. ```APIDOC ## generateIdenticon(diameter, seed) ### Description Generates a complete identicon as a DOM element. Takes a pixel diameter for sizing and an integer seed for deterministic generation. Creates a circular container with an SVG containing multiple colored, transformed rectangles. ### Method JavaScript Function ### Parameters #### Path Parameters - **diameter** (number) - Required - The pixel diameter for the generated icon. - **seed** (number) - Required - An integer seed for deterministic generation. ### Request Example ```javascript var jazzicon = require('jazzicon'); // Generate a single identicon with 100px diameter and specific seed var icon = jazzicon(100, 12345678); document.body.appendChild(icon); // Generate identicon from a wallet address (convert hex to integer) var walletAddress = '0x1234567890abcdef'; var seed = parseInt(walletAddress.slice(2, 10), 16); var walletIcon = jazzicon(48, seed); document.querySelector('.user-avatar').appendChild(walletIcon); ``` ### Response #### Success Response (DOM Element) - Returns a DOM element (SVG within a container) representing the generated identicon. #### Response Example (Returns a DOM element, not a JSON object) ``` -------------------------------- ### Generate Random Ethereum-Style Address Source: https://context7.com/danfinlay/jazzicon/llms.txt The addressGen utility function generates a random Ethereum-style address string, prefixed with '0x'. This is useful for testing and demonstration purposes, such as generating seeds for Jazzicon. ```javascript var addressGen = require('./addressGen'); // Generate a random address for testing var randomAddress = addressGen(); console.log(randomAddress); // e.g., '0x3f8a2c1d9e' // Use generated address as seed for identicon var jazzicon = require('jazzicon'); var address = addressGen(); var seed = parseInt(address.slice(2), 16); var icon = jazzicon(100, seed); document.body.appendChild(icon); ``` -------------------------------- ### Jazzicon Color Palette Source: https://context7.com/danfinlay/jazzicon/llms.txt The 'colors' module exports an array of 10 vibrant hex color values used as the base palette for identicon generation. These colors are randomly selected and hue-shifted to create visual variety. ```javascript var colors = require('./colors'); // Default color palette console.log(colors); // [ // '#01888C', // teal // '#FC7500', // bright orange // '#034F5D', // dark teal // '#F73F01', // orangered // '#FC1960', // magenta // '#C7144C', // raspberry // '#F3C100', // goldenrod // '#1598F2', // lightning blue // '#2465E1', // sail blue // '#F19E02' // gold // ] // Colors are selected randomly and hue-shifted per identicon // Each identicon uses colors from this palette with applied rotation ``` -------------------------------- ### Jazzicon - newPaper Function Source: https://context7.com/danfinlay/jazzicon/llms.txt Internal function that creates the circular container element for the identicon. It returns an object with a container property - a styled div element with border-radius for circular clipping, and the specified background color. ```APIDOC ## newPaper(diameter, color) ### Description Creates the circular container element for the identicon. Returns an object with a container property - a styled div element with border-radius for circular clipping, and the specified background color. ### Method JavaScript Function ### Parameters #### Path Parameters - **diameter** (number) - Required - The pixel diameter for the container. - **color** (string) - Required - The background color for the container (e.g., '#01888C'). ### Request Example ```javascript var paperGen = require('./paper'); // Create a circular container with teal background var elements = paperGen(100, '#01888C'); var container = elements.container; document.body.appendChild(container); ``` ### Response #### Success Response (Object) - **container** (HTMLElement) - A styled div element that acts as the circular container for the identicon. #### Response Example (Returns an object containing an HTMLElement) ``` -------------------------------- ### Jazzicon - colors Array Source: https://context7.com/danfinlay/jazzicon/llms.txt An array of 10 vibrant hex color values used as the base palette for identicon generation. The colors are randomly selected and hue-shifted during generation. ```APIDOC ## colors ### Description An array of 10 vibrant hex color values used as the base palette for identicon generation. These colors are subject to hue-shifting during the identicon generation process. ### Method JavaScript Array ### Parameters None ### Request Example ```javascript var colors = require('./colors'); // Default color palette console.log(colors); ``` ### Response #### Success Response (Array) - An array of 10 strings, where each string is a hex color code. #### Response Example ```json [ "#01888C", "#FC7500", "#034F5D", "#F73F01", "#FC1960", "#C7144C", "#F3C100", "#1598F2", "#2465E1", "#F19E02" ] ``` ``` -------------------------------- ### Create Identicon Container Element Source: https://context7.com/danfinlay/jazzicon/llms.txt The newPaper function creates a circular container element for the identicon. It returns an object containing a styled div element, which serves as the background and clipping mask for the SVG identicon. This is an internal function but can be used for custom container styling. ```javascript var paperGen = require('./paper'); // Create a circular container with teal background var elements = paperGen(100, '#01888C'); var container = elements.container; // The container is a styled div element // container.style.borderRadius = '50px' // container.style.overflow = 'hidden' // container.style.width = '100px' // container.style.height = '100px' // container.style.display = 'inline-block' // container.style.background = '#01888C' document.body.appendChild(container); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.