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

Opacity is not working on Paragraph #2210

Closed
laxman-stan opened this issue Feb 7, 2024 · 2 comments
Closed

Opacity is not working on Paragraph #2210

laxman-stan opened this issue Feb 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@laxman-stan
Copy link

Description

When opacity is applied to a Paragraph node or its parent container, (such as a Group), the text content does not inherit this opacity change.

It is acknowledged that opacity settings can be directly applied to text via the SkParagraphBuilder.pushStyle method. However, this approach presents challenges for implementing animations.

image

Version

0.1.237

Steps to reproduce

create a paragraph and try to apply opacity prop to it.

Snack, code example, screenshot, or link to a repository

import {
  Canvas,
  Group,
  Paragraph,
  Skia,
} from '@shopify/react-native-skia';

export default function Test() {

  const para = Skia.ParagraphBuilder.Make({})
    .pushStyle({
      fontSize: 60,
      color: Skia.Color('white'),
    })
    .addText('👋 hello')
    .build();

  return (
    <Canvas
      style={{flex: 1, backgroundColor: 'black'}}>
      <Group opacity={0.5}>
        <Paragraph
          opacity={0.3}
          x={0}
          y={0}
          paragraph={para}
          width={200}
        />
      </Group>
    </Canvas>
  );
}
@laxman-stan laxman-stan added the bug Something isn't working label Feb 7, 2024
@wcandillon
Copy link
Contributor

wcandillon commented Feb 7, 2024 via email

@laxman-stan
Copy link
Author

Thankyou for your prompt response.
It worked this way

<Group layer={<Paint opacity={0.5} />}>
        <Paragraph
          x={0}
          y={0}
          paragraph={para}
          width={200}
        />
</Group>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants