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

ColorMatrixFilter how to use by color #4607

Closed
neciszhang opened this issue Jan 14, 2018 · 3 comments
Closed

ColorMatrixFilter how to use by color #4607

neciszhang opened this issue Jan 14, 2018 · 3 comments

Comments

@neciszhang
Copy link

hello, i want to use a picture by use ColorMatrixFilter with color "#e73b37", how can i use by matrix Array, how to calculation? thanks a lot

@bigtimebuddy
Copy link
Member

Not exactly sure what you're looking for but:

Here's an approach which basically replicates tint using ColorMatrixFilter.

const color = new PIXI.filters.ColorMatrixFilter();
const tint = 0xe73b37;
const r = tint >> 16 & 0xFF;
const g = tint >> 8 & 0xFF;
const b = tint & 0xFF;
color.matrix[0] = r / 255;
color.matrix[6] = g / 255;
color.matrix[12] = b / 255;

https://jsfiddle.net/bigtimebuddy/4612gq30/1/

I used an approach with PixiAnimate: https://github.com/jiborobot/pixi-animate/blob/master/src/mixins/DisplayObject.js#L143-L153

The above code would allow you to do additive color as well as multiply tint.

@neciszhang
Copy link
Author

@bigtimebuddy My problem has been successfully solved! Thanks a lot! Sincerely wish you

@lock
Copy link

lock bot commented Feb 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Feb 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants