@genart-api/adapter-editart
TypeScript icon, indicating that this package has built-in type declarations

0.26.1 • Public • Published

@genart-api/adapter-editart

npm version npm downloads Mastodon Follow

GenArtAPI platform adapter for the editart.xyz art platform.

See main README for details.

Usage

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

# create dest dir
mkdir -p lib

# copy files
cp node_modules/@genart-api/core/*.min.js lib
cp node_modules/@genart-api/adapter-editart/*.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-editart"]
	}
}

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

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

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

Once running, you can then test your example in the EditArt sandbox:

https://www.editart.xyz/sandbox

Parameter handling

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 EditArt only supports at most 5 number parameters (with slider controls), only the following GenArtAPI param types can be used for projects intended for this platform. Where possible, types will be adapted, and even though the EditArt param UI controls will only ever be sliders, your artwork remain independent from these platform constraints and can still use the original param type intended (e.g. a choice param).

Params using other types will be ignored and will only ever evaluate to their assigned (or randomized) default values. When using such unsupported types, the platform adapter will log a warning message in the browser console.

Selection

This platform adapter only considers parameters with non-private .edit permissions. By default the adapter auto-selects eligible parameters (using fixed ordering rules). However, artists can manually select specific params (as long as they're supported) via an extra configuration step, e.g. by adding another <script> tag to yor HTML wrapper:

<script>
	// optional: manually specify which params (max. 5) should be exposed
	$genart.adapter.configure({ params: ["a", "b", "c"] });
</script>

If params are specified via this mechanism, no others will be considered. An error to be thrown if attempting to list more than 5 params this way.

Ordering

To ensure deterministic mapping between the 5 param values exposed by the EditArt platform and the params defined by the artwork, the platform adpater uses the following approach:

  • All non-eligible params (with unsupported types) are ignored (see earlier section)
  • Declared params are sorted by their specified .order as primary sort key and then by their ID as secondary sort key
  • Only the first max. 5 of the sorted parameters are used (mapped to EditArt's m0...m4 params).

Update behavior

EditArt doesn't support the concept of live adjustable params and any param change always triggers a full restart of the artwork.

License

© 2024 - 2025 Karsten Schmidt // MIT License

Package Sidebar

Install

npm i @genart-api/adapter-editart

Weekly Downloads

47

Version

0.26.1

License

MIT

Unpacked Size

16.7 kB

Total Files

5

Last publish

Collaborators

  • thi.ng