![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
crypto-art-render
Advanced tools
Magic render of crypto art.
npm install crypto-art-render -S
or
yarn install crypto-art-render
anchor
always be type of string
, not controlled by tokens any more.Master config defines the rule of rendering for the artwork.
A typical config data structure is shown below:
Artist
or Layer Count
.This type tells the property can be controlled by layer token or just a pure integer.
In typescript, we define:
type IntProperty = {
"token-id": number,
"lever-id": number
} or number;
A layer option defines an option of a layer that token holder can choose.
uri - Layer resource URI, usually IPFS Cid of image.
label - Layer label.
anchor - optional. Anchor point id.
fixed-position - optional. Fix position of layer at the artwork.
relative-position - optional. Relative position of layer with the coordinate of the anchor layer.
fixed-rotation (IntProperty) - optional. Fix rotation degree.
orbit-rotation (IntPropery) - optional. Orbit rotation degree around the anchor provided by the layer.
mirror (IntPropery) - optional. Mirror transition. Value result will only be 0
or 1
.
visible (IntPropery) - optional. Is layer visible. Value result will only be 0
or 1
.
finalCenterX (number) - Not pre-defined. Final center coordinate x of layer. This property will be filled during rendering process.
finalCenterY (number) - Not pre-defined. Final center coordinate y of layer. This property will be filled during rendering process.
active (boolean) - Not pre-defined. Tell the layer can be used as anchor point or not.
color - Color scheme of layer
Inherit from LayerOption, with more fields like:
Array<LayerOption>
- list of layer optionPlease see a typical master config example.
Module generator
is used to generate artwokr config, define and fill necessary fields more easily.
Check out the API.
Initialize empty config
import { Generator } from "crypto-art-render";
const generator = new Generator();
// Initialize master config with basic info
generator.intialize(
"name",
"desc",
"QmX71QqNunRjE3Sdj78vDGrDyeT3dEMp9xrrQPSx5JCBTQ"
);
// Set attributes
generator.setAttributes([
{
[KEY_TRAIT_TYPE]: "Artist",
value: "LowesYang",
},
{
[KEY_TRAIT_TYPE]: "Artist",
value: "YYH",
},
{
[KEY_TRAIT_TYPE]: "Layer Count",
value: "4",
},
]);
// Set fields in master config
generator.setLayout("layer id", 1);
generator.addStatesLayer("layer id", states);
generator.addPureLayer("layer id", layerbody);
console.log(generator.masterConfig); // see `test/config_example/example1.json`
const eosApi = new EosAPI();
// Initialize artwork on chain
// Add config file init by `generator` to IPFS node.
const configCid = "QmQRYre2kUKd3VW13CeY6zowwyK8RwXqbJxkjzpVS6cyrc";
generator.mintwork(eosApi, "contract", "artist", "issuer");
// say master id is 1, layer token relative id is 1
// the real layer token id on chaini is 1 + 1 = 2
// Setup token on chain
generator.setuptoken(eosApi, "contract", "eosio", 1, 1, [0], [256], [144]);
// Update token on chain
generator.updatetoken(eosApi, "contract", "eosio", 1, 1, [0], [145]);
Module Render
is used to render image from master config.
Check out the API.
import { Render, IpfsLoader } from "crypto-art-render";
// Initialize render with ipfs loader, interacting with local IPFS node
const render = new Render(
new IpfsLoader({ endpoint: "http://127.0.0.1:8080" })
);
// load master config
console.log(await render.loadMasterConfig("contract", masterTokenId));
// render image
const masterTokenId = 0;
const masterImage = await render.renderMaster("contract", masterTokenId);
const compositeImage = await render.renderComposite("contract", masterTokenId);
// Interact with result folloing the API of [Jimp](https://github.com/oliver-moran/jimp/tree/master/packages/jimp)
await masterImage.writeAsync("master.png");
await compositeImage.writeAsync("composite.png");
// Get current state of a artwork. It will return the hash of current
// values from layer tokens.
render.currentState(masterTokenId);
8080
.test/config_example
to local IPFS network.8888
;npm run test
FAQs
Magic render of programmable art.
We found that crypto-art-render demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.