Skip to content

Latest commit

 

History

History
141 lines (95 loc) · 4.61 KB

README.md

File metadata and controls

141 lines (95 loc) · 4.61 KB

@genart-api/adapter-layer

npm version npm downloads Mastodon Follow

GenArtAPI platform adapter for the Layer art platform.

See main README for details.

Usage

yarn add @genart-api/core @genart-api/adpater-layer

# create dest dir
mkdir -p lib

# copy files
cp node_modules/@genart-api/core/*.min.js lib
cp node_modules/@genart-api/adapter-layer/*.min.js lib

If you're a TypeScript user, you'll also want to add the types field in your tsconfig.json:

tsconfig.json:

{
	"compilerOptions": {
		"types": ["@genart-api/core", "@genart-api/adapter-layer"]
	}
}

In your HTML wrapper, add the following script tags to the <head> to load the core GenArtAPI and the Layer platform adapter:

<script src="./lib/genart.min.js"></script>
<script src="./lib/adapter-layer.min.js"></script>

See related section in main project README for more details...

Parameter type adaptations & conversions

Important

Parameter adaptation for different platforms is fully invisible to the artwork and no code changes need to be done in the artwork (which is the entire purpose of platform adapters in this system).

Because Layer only supports a small subset of the parameter types available in GenArtAPI, only the following types can be used for projects intended for this platform. Some param types will be adapted where possible. Params using other types will be skipped (i.e. not exposed to Layer) and will only ever evaluate to their default values. When using such unsupported types, the platform adapter will log a warning message in the browser console.

Choice

Reference

Will be represented as a Layer ListParameter.

Color

Reference

Will be represented as a Layer ColorParameter.

Range

Reference

Will be represented as a Layer NumberParameter.

Text

Reference

Will be represented as a Layer HashParameter. If a .match option is defined in the original param spec, it will be converted as follows:

Regexp Layer Pattern ID
^[a-zA-Z ]+$ "ALPHABETICAL"
^[a-zA-Z0-9_ ]+$ "ALPHANUMERIC"
^[a-zA-Z0-9-_=]+$ "BASE64"
^[0-9a-f]+$ "HEX"
^[0-9a-fA-F]+$ "HEX"

Any other patterns (or if unspecified) will default to the Layer target "ALPHANUMERIC" pattern.

Toggle

Reference

Will be represented as a Layer BooleanParameter.

Vector

Reference

Will be represented as multiple Layer NumberParameters, one per vector component.

Important

Your artwork will still use vectors as param value and the adapter automatically reconciles any changes done to any of the adapted params on the Layer side.

For example, a 3D vector param will be represented (on Layer's side) as three separate number params. When either of them are modified, this platform adapter will apply the changes to the correct vector component/index and propagate the changed vector via the main GenArtAPI system.

Weighted choice

Reference

Will be represented as a Layer ListParameter. Weights will be ignored when randomizing the param in the Layer GenStudio UI.

XY

Reference

Similar to vector params, XY params will also be represented as two Layer NumberParameters.

License

© 2024 - 2025 Karsten Schmidt // MIT License