Twinside / Rasterific

A drawing engine in Haskell
BSD 3-Clause "New" or "Revised" License
140 stars 11 forks source link

Group Opacity #21

Closed jeffreyrosenbluth closed 9 years ago

jeffreyrosenbluth commented 9 years ago

Consider adding a command say withOpacity that has a multiplicative effect on it's objects.

Twinside commented 9 years ago

Hmm yes I also got the problem with SVG rendering, opacity on group is wrong

Twinside commented 9 years ago

On a second thought it's not exactly the same problem, Refering to the SVG spec on opacity and more particulary it's example image reproduced here with it's source XML:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="12cm" height="3.5cm" viewBox="0 0 1200 350"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
  <desc>Example opacity01 - opacity property</desc>

  <rect x="1" y="1" width="1198" height="348"
        fill="none" stroke="blue" />

  <!-- Background blue rectangle -->
  <rect x="100" y="100" width="1000" height="150" fill="#0000ff"  />

  <!-- Red circles going from opaque to nearly transparent -->
  <circle cx="200" cy="100" r="50" fill="red" opacity="1"  />
  <circle cx="400" cy="100" r="50" fill="red" opacity=".8"  />
  <circle cx="600" cy="100" r="50" fill="red" opacity=".6"  />
  <circle cx="800" cy="100" r="50" fill="red" opacity=".4"  />
  <circle cx="1000" cy="100" r="50" fill="red" opacity=".2"  />

  <!-- Opaque group, opaque circles -->
  <g opacity="1" >
    <circle cx="182.5" cy="250" r="50" fill="red" opacity="1"  />
    <circle cx="217.5" cy="250" r="50" fill="green" opacity="1"  />
  </g>
  <!-- Group opacity: .5, opacity circles -->
  <g opacity=".5" >
    <circle cx="382.5" cy="250" r="50" fill="red" opacity="1"  />
    <circle cx="417.5" cy="250" r="50" fill="green" opacity="1"  />
  </g>
  <!-- Opaque group, semi-transparent green over red -->
  <g opacity="1" >
    <circle cx="582.5" cy="250" r="50" fill="red" opacity=".5"  />
    <circle cx="617.5" cy="250" r="50" fill="green" opacity=".5"  />
  </g>
  <!-- Opaque group, semi-transparent red over green -->
  <g opacity="1" >
    <circle cx="817.5" cy="250" r="50" fill="green" opacity=".5"  />
    <circle cx="782.5" cy="250" r="50" fill="red" opacity=".5"  />
  </g>
  <!-- Group opacity .5, semi-transparent green over red -->
  <g opacity=".5" >
    <circle cx="982.5" cy="250" r="50" fill="red" opacity=".5"  />
    <circle cx="1017.5" cy="250" r="50" fill="green" opacity=".5"  />
  </g>
</svg>

opacity01

What would the withOpacity should looks like, there is two main options:

I have a need to implement the former for rasterific-svg, but did you have in mind the behavior of the second?

cchalmers commented 9 years ago

We want group opacity (the former).

jeffreyrosenbluth commented 9 years ago

Thanks!

On Fri, Apr 3, 2015 at 7:47 AM Vincent notifications@github.com wrote:

Closed #21 https://github.com/Twinside/Rasterific/issues/21 via d5ed2b4 https://github.com/Twinside/Rasterific/commit/d5ed2b4eceec8e3548b99744d611991922c3eb57 .

— Reply to this email directly or view it on GitHub https://github.com/Twinside/Rasterific/issues/21#event-272610153.