PDA

View Full Version : Select color and Delete?


Kuma
07-05-2005, 02:36 PM
Hi,

Is there a way that through JSFL I can select a colour and then delete it?

I know that the Find and Replace (F3) has the ability to find and replace colours, but can this can't delete.

I have looked throught he Fill object but I couldn't see a select colour method.


Thanks.

Sunny13
07-06-2005, 09:39 AM
<dialog id="ColorTest" title="Colour Picker" buttons="accept, cancel"><grid> <columns> <column/> <column/> </columns> <rows> <row> <label value="Colour:" control="colpick" /> <colorpicker> <colorchip id="colpick" color="#FF0000" /> </colorpicker> </row> </rows></grid></dialog>

open the above xml in the following jsfl file as:-

var xui = fl.getDocumentDOM().xmlPanel(fl.configURI + "Commands/color.xml");if (xui) { var myColour = fl.trace("Colour: " + xui.colpick);}

Kuma
07-08-2005, 06:05 PM
Hi,

Thanks for the reply,

I have created the JSFL and the XML as you suggest.
But the above code only traces the colour value.

How can I get it to select every 'instance' of that colour in the frame?


Thanks

hangalot
07-09-2005, 05:03 PM
you will have to loop through all the elements on that frame and check what type it is, if it is a shape/fill see if you can get the color. i don't know if what you want is possible, but i suspect it is.

Sunny13
07-11-2005, 05:09 AM
Hi,
could you plz explain your problem a bit more????....hope i can help you

Kuma
07-17-2005, 10:08 PM
ok,

I want to run a JSFL command where I can select a colour in a frame.
I then want to delete the instances of that colour.

An example;

If I import an black and white drawing from Illustrator there may be hundreds of white fills which are actually not meant to be there.

It can be a royal pain to select all of these by hand, so a JSFL to do it for me would be cool.

MikkoH
11-09-2005, 09:19 PM
Well I've been wanting a similar script as this...
It works great right now if the shapes arent too complicated... I'm trying to make it better...

Heres what I do... I basically select everything... The get the selected shape...

Then get the vertices of the shape...
Go through and select nothing then select one of the vertices... IF the colour is the colour you want then delete the shape... but the only problem is that it will go through all the vertices which can be many many points...


var trace=fl.trace;
var doc=fl.getDocumentDOM();
var xui = fl.getDocumentDOM().xmlPanel(fl.configURI + "Commands/color.xml");
var vertices=new Array();
var count=0;


fl.outputPanel.clear();


if (xui)
{
var myColour = trace("Colour: " + xui.colpick);
}

doc.selectAll();


for(var r=0;r<doc.selection[0].vertices.length;r++)
{

vertices[count]=doc.selection[0].vertices[r];
count++;
}

trace(vertices.length);

for(var r=0;r<vertices.length;r++)
{
doc.selectNone();
doc.mouseClick({x:vertices[r].x, y:vertices[r].y}, false, false);

var fill = doc.getCustomFill();

if(fill.color=="'"+xui.colpick.toLowerCase()+"'")
{
doc.deleteSelection();
}
}

doc.selectNone();

MikkoH
11-09-2005, 09:25 PM
Made it a bit better... But really not a substantial difference...

var trace=fl.trace;
var doc=fl.getDocumentDOM();
var xui = fl.getDocumentDOM().xmlPanel(fl.configURI + "Commands/color.xml");


fl.outputPanel.clear();


if (xui)
{
var myColour = trace("Colour: " + xui.colpick);
}

doc.selectAll();
vertices=doc.selection[0].vertices;

for(var r=0;r<vertices.length;r++)
{
doc.selectNone();
doc.mouseClick({x:vertices[r].x, y:vertices[r].y}, false, false);

var fill = doc.getCustomFill();

if(fill.color=="'"+xui.colpick.toLowerCase()+"'")
{
doc.deleteSelection();
}
}


doc.selectNone();