Transparency 技术总结

I. Define

    Sc      source color component
    Sa      source alpha component
    Sca     source color premultiplied alpha component

    Dc      destination color component
    Da      destination alpha component
    Dca     destination color premultiplied alpha component

    Dc'     result of the destination color component
    Da'     result of the destination alpha component
    Dca'    result of the destination color premultiplied alpha component


II. Porter & Duff General Operation.

    Dca' = Fs * Sca + Fd * Dca
    Da'  = Fs * Sa  + Fd * Da
   
    Fs is function of Da
    Fd is function of Sa
   

III. Java AlphaCompositing.

    Import a const alpha value 'Ca' to source alpha
   
    Dca' = Fs * Sca * Ca + Fd * Dca
    Da'  = Fs * Sa  * Ca + Fd * Da

    Fs is function of Da
    Fd is function of Sa

IV. SVG 1.2 Draft Alpha Compositing

    On basic Porter & Duff Artical there are 12 basic type of compositing
    operations which is :
        SRC, SRC_OVER, SRC_IN, SRC_OUT, SRC_ATOP,
        DST, DSR_OVER, DST_IN, DST_OUT, DST_ATOP,
        CLEAR, XOR,
    The base set of the 12 Porter-Duff operations always result in a value
    between zero and one, no clamping of output is required.
   
    In addition of the 12 Porter-Duff operations, a number of _blending_
    operations are extensions. These may result in color and opacity values
    outside the range. (Note: premultiplied color value must in range of zero
    to the opacity value)

    Dca' = F * Sa * Da  +  Y * Sca * (1-Da)  +  Z * Dca * (1-Sa)
    Da'  = X * Sa * Da  +  Y * Sa  * (1-Da)  +  Z * Da  * (1-Sa)
   
    F is function of Sc,Dc

    CLEAR:
        F = 0, X = 0, Y = 0, Z = 0
        Dca' = 0
        Da'  = 0
   
    SRC:
        F = Sc, X = 1, Y = 1, Z = 0
        Dca' = Sca
        Da   = Sa

    DST:
        F = Dc, X = 1, Y = 0, Z = 1
        Dca' = Dca
        Da   = Da
   
    and so on.
    For detail see http://www.w3.org/TR/2004/WD-SVG12-20041027/rendering.html
   
   
V. PDF Transparency.

    Dc' = (1 - Sa/Da') * Dc + (Sa / Da') * ((1-Da) * Sc + Da * F)
    Da' = Sa + Da - Sa * Da
   
    F is function of Sc, Dc
   
    so:
   
    Dca' = (1-Sa) * Da * Dc + (1-Da) * Sa * Sc + Da * Sa * F
    Da'  = Sa + Da - Sa * Da
   
    transform to SVG form:
   
    Dca' = F * Sa * Da + Sca * (1-Da) + Dca * (1-Sa)
    Da'  =   -(Sa * Da)+ Sa           + Da
   
    so PDF.F === SVG.F
    in PDF:
        X = 1, Y = 1, Z = 1
   
   
VI.
    On each of the above. the SoftMask and ConstAlpha value can be added in.
    like this:
        Sa' = Sa * CA * SM
    Sa' is used as Sa in all above.
    Sa  is orgin alpha component of source.
    CA  is const alpha value.
    SM  is const soft mask value.

   
VII. Summary.
    ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值