Skip to main content

swatchkit 0.2.0 copy "swatchkit: ^0.2.0" to clipboard
swatchkit: ^0.2.0 copied to clipboard

A pure Dart codec for Adobe ACO, ASE, and ACT color swatch libraries.

example/main.dart

import 'dart:io';
import 'dart:typed_data';

import 'package:swatchkit/swatchkit.dart';

/// Prints the colors of one ACO, ASE, or ACT library.
Future<void> main(List<String> arguments) async {
  if (arguments.length != 1) {
    stderr.writeln('Usage: dart run example/main.dart <library.aco|ase|act>');
    exitCode = 64;
    return;
  }
  final String path = arguments.single;
  final Uint8List bytes = await File(path).readAsBytes();
  final List<(String, PsColor?)> colors = switch (path.split('.').last.toLowerCase()) {
    'aco' => [for (final AcoSwatch swatch in AcoDecoder.decode(bytes).swatches) (swatch.name ?? '', swatch.toColor())],
    'ase' => [for (final (:AseSwatch swatch, :String? group) in AseDecoder.decode(bytes).swatches) ('${group ?? '-'} / ${swatch.name}', swatch.toColor())],
    'act' => [for (final ActColor color in ActDecoder.decode(bytes).colors) ('', color.toColor())],
    _ => throw ArgumentError.value(path, 'path', 'Unsupported extension'),
  };
  for (final (String name, PsColor? color) in colors) {
    stdout.writeln('$name: ${color?.toRgb() ?? 'no process color'}');
  }
}
0
likes
160
points
229
downloads
screenshot

Documentation

API reference

Publisher

verified publisherfocale-editor.app

Weekly Downloads

A pure Dart codec for Adobe ACO, ASE, and ACT color swatch libraries.

Repository (GitHub)
View/report issues
Contributing

Topics

#photoshop #color #palette #codec #file-format

License

MIT (license)

Dependencies

pscore

More

Packages that depend on swatchkit