pixijs / pixi-react

Write PIXI apps using React declarative style
https://pixijs.io/pixi-react/
MIT License
2.42k stars 180 forks source link

Bug: Text color doesn't work #485

Open tphamz opened 7 months ago

tphamz commented 7 months ago

Current Behavior

Applying color to text doesn't seem to work. In my case, I was trying to set my text color to white using the fill attribute, with the value either "0xfff" or "white". Another issue is that when fill is an array, it only accepts numbers

Expected Behavior

Text should render color as the setting

Steps to Reproduce

Here is my sample code written in Typescript:

const nodeTextStyle = new TextStyle({
    fontSize: 20,
    fontWeight: '400',
    fill: 'pink'
  });

...
...
...
<Text text= {node.type} x = {0} y={60} anchor={0.5} style={nodeTextStyle}/>
...

Here is the result:

Screenshot 2024-04-30 at 6 59 19 PM

Environment

Possible Solution

No response

Additional Information

No response

kilisniki commented 4 weeks ago

Work around for me: <Text text={Some text} x={10} y={10} style={ new PIXI.TextStyle({ fontSize: 24, fill: 'white', // doesnt work // @ts-ignore _fill: ['#ffffff', '#00ff99'], // work pretty well }) } />