Skip to content

Make a part of an image to be transparent #2149

Closed Answered by jakex7
Themrpie asked this question in Q&A
Discussion options

You must be logged in to vote

Hey!
Yes, you can achieve that using an SVG mask, as demonstrated in this simple example (the red view is under the SVG image and is visible through the mask):

<View style={{backgroundColor: 'red'}}>
  <Svg height="400" width="400">
    <Image
      x="0"
      y="0"
      width="400"
      height="400"
      href={require('../assets/office.jpg')}
      mask="url(#mask)"
    />
    <Defs>
      <Mask id="mask" x="0" y="0" width="400" height="400">
        <Rect x="0" y="0" width="400" height="400" fill="white" />
        <Circle cx="200" cy="150" r="100" fill="black" />
      </Mask>
    </Defs>
  </Svg>
</View>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jakex7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants