Can a script change colors in a layer?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
mkelley
Posts: 1647
Joined: Fri Nov 02, 2007 5:29 pm
Location: Sunny Florida
Contact:

Can a script change colors in a layer?

Post by mkelley »

Is it possible to write a script that goes through all the shapes in a switch layer (the sub layers) and changes all with a certain color (let's say FFFFFF for the sake of argument) to a different color?

The reason I ask is I have a set of library mouths that have the skin shade as part of their construction, but to use them with different characters I need to go in manually and change each of the 10 shapes to the right color (by cutting and pasting). It's not terrible, but a script to do this would be tremendous. It must recognize and only change the shapes in all layers of that switch layer that match a certain color to another certain color.

I'm not asking anyone to write this for me -- I just want to know if it's doable (if it is it might give me the push to learn scripting).
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

Have you tried to use Styles? You define an style and apply it to a bunch of shapes. Then changing the style will change to all applied shapes.
Tutorial 2.7
-G
User avatar
heyvern
Posts: 7035
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Here's an additional tip for using styles with switch layers.

Save the mouth switch by itself as a separate document with a named style for the skin color.

Now let's say you have another character and you want to import the mouth switch. When you do the imported document will come in with its own styles. Just select the original character skin style and copy it. Select the imported skin color style and paste.

I save all kinds of stuff like this; mouths, eyes, ears, hands etc.

-vern
User avatar
mkelley
Posts: 1647
Joined: Fri Nov 02, 2007 5:29 pm
Location: Sunny Florida
Contact:

Post by mkelley »

Thanks guys.

I thought I had done all the tutorials, but I guess I missed the styles one. Vern, your workflow sounds exactly what I'm trying to do.
Post Reply