swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swftools-common] can I manipulate the color of individual objects?


From: Matthias Kramm
Subject: Re: [Swftools-common] can I manipulate the color of individual objects?
Date: Sat, 18 Dec 2004 18:18:17 +0100
User-agent: Mutt/1.5.6i

On Wed, Dec 15, 2004 at 05:19:18PM -0700, michael geary wrote:
> > i've got a strange problem. I'm working with a large batch of SWFs that
> > are being rendered out by Maya (3D software). However, Due to some
> > rendering bug, shapes that should be the same color, are very slightly
> > off. For example shape A is RGB(255,150,150), but shape B is
> > RGB(255,149,151).
> >
> > Is there any way I could create a script that could iterate through
> > each object/movieclip/whatever, determine it's color, and "snap" the
> > color to another value? Does anyone have ANY suggestions for addressing
> > such a thing? I'm afraid the way I'm using the SWFs requires the colors
> > to be EXACTLY the same.

I had a little time today to enhance the python interface of swftools a bit.
It's now possible to do what you asked for in a short python script:

#----------------------------------------------------------------------
#!/usr/bin/python2.3

import SWF

def fixColor(col):
    if 255 >= col.r >= 250 and 
       160 >= col.g >= 140 and  
       160 >= col.b >= 140:
        return SWF.Color("ff9696", col.alpha) #snap to 255,150,150
    return col

swf = SWF.load("input_file.swf")

for tag in swf.tags:
    if tag.isShape():
        for nr in range(tag.numfillstyles()):
            fs = tag.getfillstyle(nr)
            if fs.isSolid():
                fs.color = fixColor(fs.color)
            tag.setfillstyle(nr, fs)
        for nr in range(tag.numlinestyles()):
            ls = tag.getlinestyle(nr)
            ls.color = fixColor(ls.color)
            tag.setlinestyle(nr, ls)

swf.save("output_file.swf")
#----------------------------------------------------------------------

Of course, that only works for plain color fills, not bitmaps and
stuff.
It's also not colortransform-aware (I doubt that Maja is using
colortransforms, though).

Greetings

Matthias






reply via email to

[Prev in Thread] Current Thread [Next in Thread]