Skip to main content
Legend
June 13, 2017
Question

THEME_COLOR

  • June 13, 2017
  • 2 replies
  • 1233 views

Hi all,

sorry for the cross posting from Illustrator Scripting, but this might be also interesting around here.

The following works with InDesign and Illustrator.

function main()

{

  var palette = this.palette = new Window("""palette""");

  var graphics = palette.graphics;

  $.writeln("Brush:");

  var colors = ["background","disabledBackground","selection","focusRing"];

  while( colors.length ) {

    var name = colors.pop();

    $.writeln(name," = ",graphics.newBrush(graphics.BrushType.THEME_COLOR,name).color.toSource());

  }

  $.writeln();

  $.writeln("Pen:");

  var colors = ["foreground","disabledForeground","selection"];

  while( colors.length ) {

    var name = colors.pop();

    $.writeln(name," = ",graphics.newPen(graphics.PenType.THEME_COLOR,name,1).color.toSource());

  }

  $.writeln();

}

main();

Regards,

Dirk

This topic has been closed for replies.

2 replies

Loic.Aigon
Legend
June 14, 2017

Nice !!

Trevor:
Legend
June 14, 2017

Fantastic Dirk!, much better than the pathetic hacks we've been using for the past years, brilliant.

Thanks

Trevor

P.s. not sure why you are using triple quotes and this

var palette = this.palette = new Window("""palette""");

and not

var palette = new Window("palette"); 

Any light on that?

Legend
June 14, 2017

> why triple quotes

My sloppiness. That line was lifted from a member function in an Illustrator script where I used multi-line resource notation to build the palette and contained widgets. "this" stores the palette in my namespace object - AFAIK Illustrator only supports one target engine so I try to stay away from globals.

Trevor:
Legend
June 14, 2017

Actually there's at least 2 engines in Illustrator with "main" and "transient" being the standard ones.