Module: Procreate::Swatches

Defined in:
lib/procreate/swatches.rb,
lib/procreate/swatches/parser.rb,
lib/procreate/swatches/version.rb,
lib/procreate/swatches/wrapper.rb,
lib/procreate/swatches/exporter.rb,
lib/procreate/swatches/colors_helper.rb,
lib/procreate/swatches/errors/invalid_path.rb,
lib/procreate/swatches/errors/invalid_format.rb

Overview

Interact with .swatches files (Procreate) and manipulate them.

Defined Under Namespace

Modules: ColorsHelper, Errors Classes: Exporter, Parser, Wrapper

Constant Summary collapse

SWATCHES_FILE_NAME =

Internal name of the .swatches file. Used for both parsing and exporting .swatches files.

'Swatches.json'
VERSION =

Current gem version

'0.1.4'

Class Method Summary collapse

Class Method Details

.export(name, colors, options = {}) ⇒ String Also known as: to_file

Export an array of colors to a .swatches file, with the possibility to provide a custom palette name.

Parameters:

  • name (String)

    Preferred name for the exported .swatches file palette. Visible instance the Procreate app.

  • colors (Array<String, Chroma::Color>)

    An array of valid color strings or Chroma::Color instances

  • options (Hash) (defaults to: {})

    Options for exporting the wrapper

Options Hash (options):

  • :export_directory (String) — default: 'Dir.pwd'

    The export directory for the .swatches file

  • :file_name (String) — default: 'Wrapper#name'

    Custom file name for the exported .swatches file. If none is provided, the name of the wrapper instance is used

Returns:

  • (String)

    swatches_path Path of the exported .swatches file



50
51
52
53
54
# File 'lib/procreate/swatches.rb', line 50

def export(name, colors, options = {})
  wrapper = Wrapper.new(name, colors)

  Exporter.call(wrapper, options)
end

.parse(file_path) ⇒ Procreate::Swatches::Wrapper Also known as: from_file

Parse a .swatches file from the provided file path

Parameters:

  • file_path (String)

    A file path to the .swatches file

Returns:



35
36
37
# File 'lib/procreate/swatches.rb', line 35

def parse(file_path)
  Parser.call(file_path)
end