Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to create new tint swatch in javascript

Community Beginner ,
Jan 22, 2018 Jan 22, 2018

Hi Friends,

I need to create new tint swatch.

var myColor = app.activeDocument.swatches.itemByName("COLOR2");

I checked this properties. But, 'New Tint Swatch' option not there. Pls suggest friends how to create "new tint swatch". i need to change tint value.

Tint.png

Thanks

KS

TOPICS
Scripting
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Jan 22, 2018 Jan 22, 2018

var main = function(colorName, colorValues, colorTint) {

var doc = app.properties.activeDocument,

baseClr, tintClr, tintClrName, tintClrValue;

if ( !doc ) return;

if (!(  typeof ( colorName )== 'string' &&  colorName!='' ) ) {

alert( "Invalid color name parameter" );

return;

}

if (!colorTint || isNaN(colorTint) || colorTint<1 || colorTint>100 ) {

alert( "Invalid colorTint parameter" );

return;

}

baseClr = doc.swatches.itemByName ( colorName );

if ( !baseClr.isValid ) {

baseClr = doc.colors.add({

colorValue:col

...
Translate
People's Champ ,
Jan 22, 2018 Jan 22, 2018
LATEST

var main = function(colorName, colorValues, colorTint) {

var doc = app.properties.activeDocument,

baseClr, tintClr, tintClrName, tintClrValue;

if ( !doc ) return;

if (!(  typeof ( colorName )== 'string' &&  colorName!='' ) ) {

alert( "Invalid color name parameter" );

return;

}

if (!colorTint || isNaN(colorTint) || colorTint<1 || colorTint>100 ) {

alert( "Invalid colorTint parameter" );

return;

}

baseClr = doc.swatches.itemByName ( colorName );

if ( !baseClr.isValid ) {

baseClr = doc.colors.add({

colorValue:colorValues,

model:ColorModel.PROCESS,

name:colorName,

space:ColorSpace.CMYK

});

}

tintClrValue = /%/.test( colorTint )? String(colorTint).replace(/%/, "g" ) : colorTint;

tintClrValue = Number ( tintClrValue );

tintClrName = colorName +" "+tintClrValue+"%";

tintClr  = doc.swatches.itemByName ( tintClrName );

if ( !tintClr.isValid ) {

tintClr = doc.tints.add(baseClr, {

tintValue:tintClrValue,

});

}

}

var u;

app.doScript ( "main('blue', [100,30,0,0], 80)",u,u,UndoModes.ENTIRE_SCRIPT, "The Script" );

HTH

Loic Aigon

Ozalto | Productivity Oriented - Loïc Aigon

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines