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

Not work ClipPath/Path on Android #280

Closed
eXist-FraGGer opened this issue Mar 12, 2017 · 11 comments
Closed

Not work ClipPath/Path on Android #280

eXist-FraGGer opened this issue Mar 12, 2017 · 11 comments

Comments

@eXist-FraGGer
Copy link

eXist-FraGGer commented Mar 12, 2017

1.)

            <Svg width="200" height="150" viewBox="6 0 200 160" >
                <G>
                    <Defs>
                        <ClipPath
                            id="clip-path">
                            <Path d="M179.33,9.5H13.83S6.1,9.38,3.33,6.58A19,19,0,0,1,0,1.83V123.17A17.33,17.33,0,0,0,17.33,140.5h162a17.33,17.33,0,0,0,17.33-17.33V26.83A17.33,17.33,0,0,0,179.33,9.5Z"
                                fill="none" />
                        </ClipPath>
                    </Defs>
                    <G clipPath="url(#clip-path)">
                        <Image
                            width="240"
                            height="150"
                            href={this.props.image}/>
                    </G>
                </G>
            </Svg>
        </View>

2.) Run on ios - All good!
screenshot at 13 12-28-04

3.) Run on android - Does not work
ys3uqowkt0o

Why ?

@eXist-FraGGer eXist-FraGGer changed the title Failed prop type: The prop href is marked as required in Image, but its value is undefined Not work ClipPath/Path on Android Mar 13, 2017
@SteveIb
Copy link

SteveIb commented May 30, 2017

Can I use this.state.image instead of this.prop.image?
href={this.state.image}

@jeggy
Copy link

jeggy commented Oct 24, 2017

Did you find out why it's not working?

@logvi
Copy link

logvi commented Dec 15, 2017

+1

@dusave
Copy link

dusave commented Dec 16, 2017

If others are still having issues with this, please post your versions of react-native-svg, react-native, and android to help narrow down the problem.

@logvi
Copy link

logvi commented Dec 18, 2017

@dustinsavery
"react-native-svg": "^6.0.0",
"react-native": "0.50.3",
android 5.1.1

clipPath prop for Image is not working. This is my code:

<Svg
  height="100"
  width="100"
>
<Defs>
   <ClipPath id="clip">
          <G>
             <Path d="M 50 100 A 50 50 0 0 0 50 0 L 50 50" />
          </G>
   </ClipPath>
</Defs>
<Image
   width="100%"
   height="100%"
   href={URL}
   clipPath="url(#clip)"
/>
</Svg>

@dusave
Copy link

dusave commented Dec 18, 2017

@logvi thanks for posting, I'll take a look

@mleoanbarasan
Copy link

@dustinsavery I am also facing the same problem of ClipPath is not working in android, whereas it is working fine in iOS. Can you provide me the alternative or work around for this issue?

Awaiting for your reply.

@dusave
Copy link

dusave commented Jan 12, 2018

I haven't had any success locating the source of the problem. I am no android expert though. Hopefully someone with more android experience can help here.

@gogolubev
Copy link

Same problem at 6.3.1 version. For iOS everything is fine, but on android ClipPath doesn't working. Is there some solution?

@AricWu
Copy link

AricWu commented Jul 21, 2018

Well,I have the same problem too,

           <G clipPath="url(#clip-path)">
                        <Image
                            width="240"
                            height="150"
                            href={this.props.image}/>
              </G>

working fine in iOS , And in android it does not work,
but I find that in Android you can write 'clipPath' in <Image/> and it work fine,

 <G >
                        <Image
                            width="240"
                            height="150"
                            href={this.props.image}
                            clipPath="url(#clip-path)"
                          />
 </G>

(This code work different in iOS)

The second code in Android it run good, but run different in iOS. I Because the origin point and Y-axis direction is different .
So I use first code in iOS and run second code in iOS ,then they work fine.

@msand
Copy link
Collaborator

msand commented Sep 1, 2018

I've fixed the transform handling for ClipPath on Android, and the spec conformance on both iOS and Android. Any help in testing would be much appreciated! msand@a1097b8

@msand msand closed this as completed in a1097b8 Sep 15, 2018
sivakumar-cf added a commit to curefit/react-native-svg that referenced this issue Sep 10, 2019
https://www.w3.org/TR/SVG11/masking.html#EstablishingANewClippingPath

The raw geometry of each child element exclusive of rendering properties such as ‘fill’, ‘stroke’, ‘stroke-width’ within a ‘clipPath’ conceptually defines a 1-bit mask (with the possible exception of anti-aliasing along the edge of the geometry) which represents the silhouette of the graphics associated with that element. Anything outside the outline of the object is masked out. If a child element is made invisible by ‘display’ or ‘visibility’ it does not contribute to the clipping path. When the ‘clipPath’ element contains multiple child elements, the silhouettes of the child elements are logically OR'd together to create a single silhouette which is then used to restrict the region onto which paint can be applied. Thus, a point is inside the clipping path if it is inside any of the children of the ‘clipPath’.

For a given graphics element, the actual clipping path used will be the intersection of the clipping path specified by its ‘clip-path’ property (if any) with any clipping paths on its ancestors, as specified by the ‘clip-path’ property on the ancestor elements, or by the ‘overflow’ property on ancestor elements which establish a new viewport. Also, see the discussion of the initial clipping path.)

Fixes issues highlighted by software-mansion#752
Fix software-mansion#280
Fix software-mansion#517

[android] Fix software-mansion#766
`Region.Op.REPLACE` is deprecated in API level 28
Replace with clipPath (Path path) to Intersect instead.
JackWillie added a commit to JackWillie/react-native-svg that referenced this issue Nov 27, 2022
https://www.w3.org/TR/SVG11/masking.html#EstablishingANewClippingPath

The raw geometry of each child element exclusive of rendering properties such as ‘fill’, ‘stroke’, ‘stroke-width’ within a ‘clipPath’ conceptually defines a 1-bit mask (with the possible exception of anti-aliasing along the edge of the geometry) which represents the silhouette of the graphics associated with that element. Anything outside the outline of the object is masked out. If a child element is made invisible by ‘display’ or ‘visibility’ it does not contribute to the clipping path. When the ‘clipPath’ element contains multiple child elements, the silhouettes of the child elements are logically OR'd together to create a single silhouette which is then used to restrict the region onto which paint can be applied. Thus, a point is inside the clipping path if it is inside any of the children of the ‘clipPath’.

For a given graphics element, the actual clipping path used will be the intersection of the clipping path specified by its ‘clip-path’ property (if any) with any clipping paths on its ancestors, as specified by the ‘clip-path’ property on the ancestor elements, or by the ‘overflow’ property on ancestor elements which establish a new viewport. Also, see the discussion of the initial clipping path.)

Fixes issues highlighted by software-mansion/react-native-svg#752
Fix software-mansion/react-native-svg#280
Fix software-mansion/react-native-svg#517

[android] Fix software-mansion/react-native-svg#766
`Region.Op.REPLACE` is deprecated in API level 28
Replace with clipPath (Path path) to Intersect instead.
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

9 participants