Saturday, October 29, 2011

Expand a raster tracing object

This week Hugo Tait sent me an excellent question about how to expand a tracing object.

Unfortunately, there wasn't much of an example in the javascript guide.
It took a little experimentation, but I came up with the following script, and thought I'd share it with all of you here. This will take the current selected Raster object (embedded not placed) and convert it into 4 color geometry.

var doc = activeDocument;
var obj = doc.selection[0];
var r = obj.trace();
var options = r.tracing.tracingOptions;
options.tracingMode = TracingModeType.TRACINGMODECOLOR;
options.ignoreWhite=true;
options.maxColors=4;
redraw();
r.tracing.expandTracing();

cheers,
-J