Class Index | File Index

Classes


Namespace jamBooks


Version 4.5.1.

Defined in: jamBooks.jsxinc.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
Global object (used to simulate a namespace in JavaScript) containing a set of color books-related functions for scripts written with the JSON Action Manager engine.
Method Summary
Method Attributes Method Name and Description
<static>  
jamBooks.dataFromColorBookFile(colorBookFile, actualComponents)
Parse a color book file (*.acb) into a data structure in JSON object format.
<static>  
jamBooks.dataToColorBookFile(colorBookFile, colorBookData)
Generate a color book file (*.acb) from a data structure in JSON object format.
<static>  
jamBooks.getColorBookFileColors(colorBookFile, roundComponents)
Get the list of colors from a color book file (*.acb).
<static>  
jamBooks.isColorBookFile(file)
Test if a given file is a color book file (*.acb).
Namespace Detail
jamBooks
Global object (used to simulate a namespace in JavaScript) containing a set of color books-related functions for scripts written with the JSON Action Manager engine.
Uses information found in the documents Adobe Color Book File Format Specification and Adobe Photoshop File Formats Specification.
Author: Michel MARIANI.
Method Detail
<static> {Object|String} jamBooks.dataFromColorBookFile(colorBookFile, actualComponents)
Parse a color book file (*.acb) into a data structure in JSON object format.
var acbFilter =
    (File.fs === "Macintosh") ?
        function (f) { return (f instanceof Folder) || jamBooks.isColorBookFile (f) } :
        "Color Book Files:*.acb,All Files:*.*";
var colorBookFile = File.openDialog ("Open color book file:", acbFilter);
if (colorBookFile)
{
    var colorBookData = jamBooks.dataFromColorBookFile (colorBookFile);
    if (typeof colorBookData === 'string')
    {
        alert ("Error: " + colorBookData);
    }
    else
    {
        alert ("Color space: " + colorBookData["colorSpace"]);
        alert ("Number of colors: " + colorBookData["colors"].length);
    }
}
Parameters:
{String|Object} colorBookFile
Color book file path string or File object
{Boolean} actualComponents Optional
List actual color components instead of raw color components
Returns:
{Object|String} Parsed color book file data structure in JSON object format, or error message string
See:
jamBooks.dataToColorBookFile

<static> {String} jamBooks.dataToColorBookFile(colorBookFile, colorBookData)
Generate a color book file (*.acb) from a data structure in JSON object format.
var jsonFilter =
    (File.fs === "Macintosh") ?
        function (f) { return (f instanceof Folder) || f.name.match (/\.json$/i) } :
        "JSON Text Files:*.json,All Files:*.*";
var jsonFile = File.openDialog ("Open JSON text file:", jsonFilter);
if (jsonFile)
{
    var colorBookData = jamUtils.readJsonFile (jsonFile);
    if (colorBookData)
    {
        var result = jamBooks.dataToColorBookFile ("~/Desktop/color-book.acb", colorBookData);
        if (result)
        {
            alert ("Error: " + result);
        }
        else
        {
            alert ("Color book file generated on Desktop.");
        }
    }
    else
    {
        alert ("Invalid JSON text file!");
    }
}
Parameters:
{String|Object} colorBookFile
Color book file path string or File object
{Object} colorBookData
Color book file data structure in JSON object format
Returns:
{String} Error message string (empty if no error)
See:
jamBooks.dataFromColorBookFile

<static> {Object|Null} jamBooks.getColorBookFileColors(colorBookFile, roundComponents)
Get the list of colors from a color book file (*.acb).
var acbFilter =
    (File.fs === "Macintosh") ?
        function (f) { return (f instanceof Folder) || jamBooks.isColorBookFile (f) } :
        "Color Book Files:*.acb,All Files:*.*";
var colorBookFile = File.openDialog ("Open color book file:", acbFilter);
if (colorBookFile )
{
    var colorBookColors = jamBooks.getColorBookFileColors (colorBookFile, true);
    if (colorBookColors)
    {
        alert ("First color:\r"+ jamJSON.stringify (colorBookColors["bookColors"][0], '\t'));
    }
}
Parameters:
{String|Object} colorBookFile
Color book file path string or File object
{Boolean} roundComponents Optional
Round color components
Returns:
{Object|Null} List of colors from a color book file (*.acb), or null if error

<static> {Boolean} jamBooks.isColorBookFile(file)
Test if a given file is a color book file (*.acb).
function colorBookFileFilter (f)
{
    return (f instanceof Folder) || jamBooks.isColorBookFile (f);
}
var select = (File.fs === "Macintosh") ? colorBookFileFilter : "Color Book Files:*.acb,All Files:*";
var colorBookFile = File.openDialog ("Select a color book file:", select);
if (colorBookFile !== null)
{
    alert ("OK!");
}
Parameters:
{Object} file
File object
Returns:
{Boolean} true if color book file

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Oct 12 2016 23:32:44 GMT+0200 (CEST)