OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

# cgmo-webcgm message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Re: [cgmo-webcgm] Drawing model (take 2)

• From: Lofton Henderson <lofton@rockynet.com>
• To: Benoit Bezaire <benoit@itedo.com>,cgmo-webcgm@lists.oasis-open.org
• Date: Thu, 20 Apr 2006 08:36:40 -0600

```[...1 of 2...]

I'll write more about Benoit's questions in next message.  But for now, a
technical nit...

I wonder if there's a bug in the equations?

>[...]
>WebCGM uses a painters model of rendering. Colors are applied in
>successive operations to the output device. When an area overlaps a
>previously colored area the new color partially or completely obscures
>the old. When the color is not completely opaque the result on the
>output device is defined by the following (mathematical) rules for
>compositing (all color values use premultiplied alpha):
>
>Pr, Pg, Pb    - Primitive color value
>Pa            - Primitive alpha value
>Cr, Cg, Cb    - Canvas color value (before blending)
>Ca            - Canvas alpha value (before blending)
>Cr', Cg', Cb' - Canvas color value (after blending)
>Ca'           - Canvas alpha value (after blending)
>Ca' = 1 - (1 - Pa) * (1 - Ca)

Are the following equations correct?  If primitive is fully transparent
red, for example (0, 1, 0, 0), then it should not affect the canvas,
right?  I.e., intuitively Cr'=Cr.  But the equation gives,

Cr' = Cr + Pr

Similarly, the equation gives intuitively wrong result for Pa=1 (fully
opaque).  So I think the equation actually needs to be:

Cr' = (1 - Pa)*Cr + Pa*Pr

Thoughts?

-Lofton.

>Cr' = (1 - Pa) * Cr + Pr
>Cg' = (1 - Pa) * Cg + Pg
>Cb' = (1 - Pa) * Cb + Pb
>
>Example #1:
>Primitive is semi transparent red: (Pa, Pr, Pg, Pb) = (0.5,0.5,0,0)
>Canvas is opaque black: (Ca, Cr, Cg, Cb) = (1,0,0,0)
>Ca' = 1 - (1 - 0.5) * (1 - 1) = 1
>Cr' = (1 - 0.5) * 0 + 0.5 = 0.5
>Cg' = (1 - 0.5) * 0 + 0 = 0
>Cb' = (1 - 0.5) * 0 + 0 = 0
>The result is an opaque dark red (1,0.5,0,0).
>
>Example #2:
>Primitive is opaque red: (Pa, Pr, Pg, Pb) = (1,1,0,0)
>Canvas is semi transparent black: (Ca, Cr, Cg, Cb) = (0.5,0,0,0)
>Ca' = 1 - (1 - 1) * (1 - 0.5) = 1
>Cr' = (1 - 1) * 0 + 1 = 1
>Cg' = (1 - 1) * 0 + 0 = 0
>Cb' = (1 - 1) * 0 + 0 = 0
>The result is an opaque red (1,1,0,0).
>
>Example #3:
>Primitive is semi transparent red: (Pa, Pr, Pg, Pb) = (0.5,0.5,0,0)
>Canvas is semi transparent black: (Ca, Cr, Cg, Cb) = (0.5,0,0,0)
>Ca' = 1 - (1 - 0.5) * (1 - 0.5) = 0.75
>Cr' = (1 - 0.5) * 0 + 0.5 = 0.5
>Cg' = (1 - 0.5) * 0 + 0 = 0
>Cb' = (1 - 0.5) * 0 + 0 = 0
>The result is a transparent dark red (0.75,0.5,0,0).

```

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]