{"id":19441502,"url":"https://github.com/dgca/onchain-image-renderers","last_synced_at":"2025-04-25T00:30:48.236Z","repository":{"id":213006405,"uuid":"732773750","full_name":"dgca/onchain-image-renderers","owner":"dgca","description":"A collection of Solidity contracts that render pixel art directly from EVM blockchains","archived":false,"fork":false,"pushed_at":"2024-04-26T22:09:50.000Z","size":100,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-27T22:29:53.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-17T19:28:20.000Z","updated_at":"2024-04-27T10:02:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"d50e96ad-8cf6-42cb-815e-61422b0f68f3","html_url":"https://github.com/dgca/onchain-image-renderers","commit_stats":null,"previous_names":["dgca/solidity-pixel-art-renderers","dgca/onchain-image-renderers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgca%2Fonchain-image-renderers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgca%2Fonchain-image-renderers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgca%2Fonchain-image-renderers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgca%2Fonchain-image-renderers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgca","download_url":"https://codeload.github.com/dgca/onchain-image-renderers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223973554,"owners_count":17234475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T15:35:53.701Z","updated_at":"2025-04-25T00:30:48.221Z","avatar_url":"https://github.com/dgca.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Onchain Image Renderers\n\nThis project is a collection of Solidity contracts that allow users to generate art on-chain.\n\n## BitmapRendererV1\n\n`BitmapRendererV1` allows callers to generate bitmap images onchain. Images can be generated in two formats: 8-bit and 24-bit. The 8-bit images are generated using a palette and an array of indices, while the 24-bit images are generated using an array of RGB values.\n\nGenerally, the 8-bit images are more gas efficient than the 24-bit images, but the 24-bit images provide more flexibility in terms of color selection.\n\nBoth 8-bit and 24-bit images can be generated as raw bitmap data or as base64 encoded strings. The function signature for generating base64 encoded images is the same as the function signature for generating raw bitmap data, with the only difference being the return type.\n\n### Addresses\n\n- [Base Mainnet](https://basescan.org/address/0x4256dee61336fcf9325934fcee207bd08d3b5809): `0x4256dee61336fcf9325934fcee207bd08d3b5809`\n- [Base Sepolia](https://sepolia.basescan.org/address/0x4256dee61336fcf9325934fcee207bd08d3b5809): `0x4256dee61336fcf9325934fcee207bd08d3b5809`\n- [Ink Mainnet](https://explorer.inkonchain.com/address/0xe0413ff96366c1c6c6222892e82cabb867f50d44): `0xe0413ff96366c1c6c6222892e82cabb867f50d44`\n\n### 8-bit image creation\n\n- `create8bitBMPData(...) external pure returns (bytes memory)`\n- `createBase64Encoded8bitBMP(...) pure returns (string memory)`\n\nNote: Both functions take the same arguments. For the sake of simplicity, we'll only look at the `create8bitBMPData` function below.\n\n```sol\nfunction create8bitBMPData(\n    uint8 width,\n    uint8 height,\n    uint256[] memory palette,\n    uint8[] memory data\n) external pure returns (bytes memory);\n```\n\nIn order to generate an 8-bit image, the caller must provide the width and height of the image, a palette of colors, and an array of numbers that indicate the index of the color to use for that pixel.\n\nThe palette is colors to be used in the image, represented as an array of `uint256`. Each `uint256` should represent an RGB color value in hex format. E.g. pure red would be 0xFF0000, pure green would be 0x00FF00, and pure blue would be 0x0000FF.\n\nThe data array is an array of numbers where each number represents the index of the color in the palette to use for that pixel. Pixels are written top left to bottom right.\n\nFor example, to generate a 3 by 3 image where the colors are as follows:\n\n```\nred,green,blue\nwhite,black,white\nblue,green,red\n```\n\nThe caller would do the following:\n\n```sol\nbytes memory result = IBitmapRendererV1(contractAddress).create8bitBMPData(\n    3,\n    3,\n    [\n        0xFF0000, // 0: red\n        0x00FF00, // 1: green\n        0x0000FF, // 2: blue\n        0xFFFFFF, // 3: white\n        0x000000  // 4: black\n    ],\n    [\n        0, 1, 2,\n        3, 4, 3,\n        2, 1, 0\n    ]\n);\n```\n\n### 24-bit image creation\n\n- `create24bitBMPData(...) external pure returns (bytes memory)`\n- `createBase64Encoded24bitBMP(...) pure returns (string memory)`\n\nNote: Both functions take the same arguments. For the sake of simplicity, we'll only look at the `create24bitBMPData` function below.\n\n```sol\nfunction create24bitBMPData(\n    uint8 width,\n    uint8 height,\n    uint8[] memory data\n) external pure returns (bytes memory);\n```\n\nIn order to generate a 24-bit image, the caller must provide the width and height of the image, and an array of RGB values.\n\nThe data array is an array of numbers where each number represents the RGB value of the pixel. Pixels are written top left to bottom right.\n\nFor example, to generate a 3 by 3 image where the colors are as follows:\n\n```\nred,green,blue\nwhite,black,white\nblue,green,red\n```\n\nThe caller would do the following:\n\n```sol\nbytes memory result = IBitmapRendererV1(contractAddress).create24bitBMPData(\n    3,\n    3,\n    [\n        0xFF0000, 0x00FF00, 0x0000FF,\n        0xFFFFFF, 0x000000, 0xFFFFFF,\n        0x0000FF, 0x00FF00, 0xFF0000\n    ]\n);\n```\n\n## SVGRendererV1\n\n...todo...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgca%2Fonchain-image-renderers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgca%2Fonchain-image-renderers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgca%2Fonchain-image-renderers/lists"}