-
| 
         Hello people. I'm trying to take an image and make a part of it transparent, is it possible with this library? I've been able to create part of the image to not be seen by adding a Mask or a Path, but haven't been able to make it transparent, is it possible? 
 Hopefully somebody can help.  | 
  
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
| 
         Hi @Themrpie function App(): JSX.Element {
  const skimage = useImage('https://picsum.photos/200/300');
  // const svg = useSVG(require('./assert/svg/Vector.svg'));
  const ref = useCanvasRef();
  useEffect(() => {
    setTimeout(() => {
      // you can pass an optional rectangle
      // to only save part of the image
      const image = ref.current?.makeImageSnapshot();
      if (image) {
        // you can use image in an <Image> component
        // Or save to file using encodeToBytes -> Uint8Array
        const bytes = image.encodeToBase64(ImageFormat.PNG, 100);
        console.log(bytes)
      }
    }, 1000)
  });
  return (
    <SafeAreaView>
      <Canvas style={{width: 256, height: 256}} ref={ref}>
        <Mask
          mode="luminance"
          mask={
            <Group>
              <Fill color={'white'} />
              <Circle cx={128} cy={128} r={64} />
            </Group>
          }>
          <Image
            image={skimage}
            fit="contain"
            x={0}
            y={0}
            width={256}
            height={256}
          />
        </Mask>
      </Canvas>
    </SafeAreaView>
  );
} | 
  
Beta Was this translation helpful? Give feedback.

Hi @Themrpie
I don't fully understand what your problem is, but these lines of code may help you.
Additionally, there is documentation on how to use Mask , but many people still cannot use it