@le7el/generative_art
Version:
Solidity libraries to generate on-chain graphics
57 lines (29 loc) • 1.48 kB
Markdown
Set of Solidity libraries to create on-chain graphics.
Install [Foundry](https://getfoundry.sh/).
Run tests: `forge test`
npm i @le7el/generative_art
Deterministically generates an SVG image with pixel as a rectangle of 9x9 pixels colored by random colors.
Deterministically generates SVG rectangle notation (without `<svg>` enclosement) for pixel cloud of 9x9 pixels colored by random colors.
### renderText(string memory seed)
Render white colored text for 9x9 SVG canvas.
### renderImage(string memory innerContent)
Wrap inner SVG notations with `<svg>` wrapper tag.
## EncodeUtils
### base64(bytes memory data)
Base64 encoding, keep in mind that `\` required double escaping like `\\r\\n`.
### attributeForTypeAndValue(string memory traitType, string memory value, bool isNumber)
JSON encode attribute and value into `{"trait_type":"[traitType]","value":"[value]"}` dictionary record.
JSON encode metadata chunk as `"name":"value",` for further JSON rendering.
Get a byte length of a string.
Get a substring between `startIndex` and `endIndex`, excluding the `endIndex` character.