Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to get same image inside two circles which are overlapping in middle #1233

Closed
akshaypilankar opened this issue Jan 2, 2020 · 5 comments

Comments

@akshaypilankar
Copy link

hello,
i am trying to create a component in which one small circle overlaps another big circle in middle and Image tag is used to show same background in both the circles with clip path but here issue is
image is not shown in overlapping parts of circles. please help i have image attached about the same.
demo image
this is my code

 <ImageBackground source={require('../assets/images/20.png')} style={styles.background}>
                    <Svg height={height} width="100%">
                        <Defs>
                            <ClipPath id="clip">
                                <Circle cx="80" cy="150" r="180" />
                                <Circle cx="320" cy="230" r="250" />
                            </ClipPath>
                        </Defs>
                        <Image
                            href={require('../assets/images/18.jpg')}
                            width={500}
                            height={500}
                            preserveAspectRatio="xMinYMin slice"
                            clipPath="url(#clip)"
                        />
                    </Svg>
        </ImageBackground>
@msand
Copy link
Collaborator

msand commented Jan 3, 2020

Can you try with the latest commit from the develop branch, and setting clipRule="nonzero" on the ClipPath element?

You can add something like clipPath=" " to the ClipPath element to workaround the prop extraction logic i just found like this: https://snack.expo.io/@msand/workaround-clippath-clip-rule-parsing

import * as React from 'react';
import { Text, View, StyleSheet, ImageBackground } from 'react-native';
import { Svg, Defs, ClipPath, Circle, Image, G } from 'react-native-svg';
import Constants from 'expo-constants';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Svg height="100%" width="100%">
          <Defs>
            <ClipPath id="clip" clipRule="nonzero" clipPath=" ">
              <Circle cx="80" cy="150" r="180" />
              <Circle cx="320" cy="230" r="250" />
            </ClipPath>
          </Defs>
          <Image
            href={require('./assets/snack-icon.png')}
            width={500}
            height={500}
            preserveAspectRatio="xMinYMin slice"
            clipPath="url(#clip)"
          />
        </Svg>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    paddingTop: Constants.statusBarHeight,
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
});

@msand msand closed this as completed in f93bdde Jan 4, 2020
msand pushed a commit that referenced this issue Jan 4, 2020
# [9.14.0](v9.13.6...v9.14.0) (2020-01-04)

### Bug Fixes

* **android:** correct values for measureInWindow, fixes [#1231](#1231) ([3bf07f8](3bf07f8))
* **android:** elements not touchable if below opacity limit ([ebc7220](ebc7220)), closes [#1200](#1200)
* **android:** fix radial gradient vertical center offset scaling ([d5bddd5](d5bddd5))
* **ios:** crash when offset is outside range [#1201](#1201) ([a2ef51f](a2ef51f))
* **web:** fix gesture responder dimensions measurement ([36c20b3](36c20b3))
* extraction of clip rule, fixes [#1233](#1233) ([f93bdde](f93bdde))
* Text color doesn't work with inlineSize [#1225](#1225) ([027b8c1](027b8c1))

### Features

* **android:** support using other native views in e.g. masks ([15b4ac6](15b4ac6))
* **ios:** support using other native views in e.g. masks ([518a3b1](518a3b1))
* **web:** Implement support for event, touch & responder handlers ([60561ec](60561ec))
* **web:** Optimize: only set responders if press handler exists ([23250ad](23250ad))
* Implement display="none" ([3e3ad13](3e3ad13)), closes [#1220](#1220)
@msand
Copy link
Collaborator

msand commented Jan 4, 2020

🎉 This issue has been resolved in version 9.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@msand msand added the released label Jan 4, 2020
@msand
Copy link
Collaborator

msand commented Jan 4, 2020

Released in v10

@AnthonyLabaere
Copy link

This issue is still present in v12.3.0 (currently recommended by expo).

@wodin
Copy link

wodin commented Dec 22, 2023

This can be worked around using a Mask. See #1520 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants