Rust and WebAssembly library to encode and create Adobe Swatch Exchange (ASE) files for colors and palettes.
This project is based on the swatch library by Marcos A Ojeda written in Python.
```rust use aseswatch::createase; use ase_swatch::types::*;
let swatches = vec![
ObjectSwatch {
name: "Palette 1".tostring(),
swatches: vec![
ObjectColor {
name: "Red".tostring(),
objecttype: ObjectColorType::Global,
data: Color {
mode: ColorMode::Rgb,
values: vec![1.0, 0.0, 0.0],
},
},
ObjectColor {
name: "Green".tostring(),
objecttype: ObjectColorType::Global,
data: Color {
mode: ColorMode::Rgb,
values: vec![0.0, 1.0, 0.0],
},
},
ObjectColor {
name: "Blue".tostring(),
objecttype: ObjectColorType::Global,
data: Color {
mode: ColorMode::Rgb,
values: vec![0.0, 0.0, 1.0],
},
},
],
}
];
let colors = vec![
ObjectColor {
name: "Blue".tostring(),
objecttype: ObjectColorType::Global,
data: Color {
mode: ColorMode::Rgb,
values: vec![0.0, 0.0, 1.0],
},
},
];
let result: Vec
Prerequisite steps:
wasm-pack
with appropriate build target.The library exposes a create_ase_js()
function that can be called from JavaScript with a similar signature to create_ase
function.
javascript
const swatches = [
{
name: "Palette 1",
swatches: [
{
name: "Red",
object_type: "Global",
data: {
mode: "Rgb",
values: [1.0, 0.0, 0.0],
},
},
{
name: "Green",
object_type: "Global",
data: {
mode: "Rgb",
values: [0.0, 1.0, 0.0],
},
},
{
name: "Blue",
object_type: "Global",
data: {
mode: "Rgb",
values: [0.0, 0.0, 1.0],
},
},
],
},
];
let colors = [
{
name: "Blue",
object_type: "Global",
data: {
mode: "Rgb",
values: [0.0, 0.0, 1.0],
},
},
];
const result = create_ase_js(swatches, colors);
// resulting array is a `Uint8Array` of the created ASE file
ase-swatch is MIT Licensed