Salir
  • Comunidad global
    • Idioma:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

How to create new tint swatch in javascript

Principiante de comunidad ,
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

TEMAS
Scripts
1.4K
Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines

correct answers 1 respuesta correcta

Campeón , 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

...
Traducir
Campeón ,
Jan 22, 2018 Jan 22, 2018
MÁS RECIENTES

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

Traducir
Informe
Directrices de la comunidad
Sé amable y respetuoso, muestra títulos de crédito de la fuente de contenido original y busca duplicados antes de publicar. Más información
community guidelines