Jump to content
Search Community

SVG Mask Problem

chris_r test
Moderator Tag

Recommended Posts

Warning: mask newbie here.

I'm applying a mask in an SVG per the link below but it's not working.

https://developer.mozilla.org/en-US/docs/Web/SVG/Element/mask

 

The way I read it, white reveals, black hides (filled  rects inside the mask def).

I'm applying the mask to a group (the husky head).

The mask should be the same area as the rounded rectangle visible behind the dog head.

So theoretically the dog head should be masked to just inside the rounded rectangle.

Any insight appreciated...

 

UPDATE: I fixed the issue per Craig's advice, so Codepen now shows a properly functioning mask.

 

See the Pen gOpzLyV by crawley27 (@crawley27) on CodePen

Link to comment
Share on other sites

Best not to scale the group you're masking. Try using a parent group around the one you'll be scaling and mask the parent. 

 

 <g mask="url(#masker)">
   <g id="husky-color" >
    <!-- paths  -->
  </g>
</g>

Looks like you'll need to make some change to the mask position and rectangle too since you're using a nested SVG with a different viewBox. For the record, I'd strongly recommend not using nested SVGs as they're nothing but trouble. Just my two cents.

 

Hopefully that helps. Happy tweening.

 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...