kuoruan Posted May 14, 2018 Share Posted May 14, 2018 I want to draw a simple polygon with gradient background color in Pixi.graphics. like the createLinearGradient do. But I can't find the correct way. Should I use a filter, and need to custom a filter? https://github.com/pixijs/pixi.js/wiki/v4-Creating-Filters I find some post: But I can't really understand. Can any one give me a sample? Quote Link to comment Share on other sites More sharing options...
jonforum Posted May 14, 2018 Share Posted May 14, 2018 you can maybe take a look how linear gardien are made with text. https://goo.gl/j9AqD2 I suppose it the same way to use in graphics. Quote Link to comment Share on other sites More sharing options...
kuoruan Posted May 14, 2018 Author Share Posted May 14, 2018 @jonforum But Pixi.graphics dose not has the API like text. Quote Link to comment Share on other sites More sharing options...
kuoruan Posted May 14, 2018 Author Share Posted May 14, 2018 Found a solution but not so good. https://stackoverflow.com/questions/48370902/pixi-js-draw-rectangle-with-gradient-fill/48521127#48521127 Quote Link to comment Share on other sites More sharing options...
botmaster Posted May 16, 2018 Share Posted May 16, 2018 You could probably make a clone of the graphics fragment source and implement gradient in there. Quote Link to comment Share on other sites More sharing options...
Ming Iu Posted May 16, 2018 Share Posted May 16, 2018 You could also create the gradient as a separate object, and then you can mask it out with a polygon. Here's an example. In that example, I'm using a vector drawing for the gradient, but since gradients don't become blurry when resized, you could probably use a sprite for that as well. I'm not sure if masks have good performance, but if you just need a few of them, then it's probably fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.