Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
A couple people over in the FAST pinball Slack mentioned wanting to have gradient text without the need for bitmaps so they could adjust it a bit easier. I was looking for an excuse to try compiling mpf so I've gone ahead and added a new linear_gradient effect for the display widget.
The effect supports an arbitrary number of color stops and rotation of the gradient. It's applied using a "multiply" blend mode but future enhancements could be made to support other blend modes too. I chose to start with multiply since I feel it covers a broad range of use-cases.
There is a slight black outline around text which has had the effect applied. As best I can tell, this isn't related to the shader as it's still there even if you change the shader's code to return a solid color and only keep the alpha channel. I suspect this has something to do with the anti-aliasing of the text but I couldn't say for sure. Either way, I think it still produces a nice effect and this outline does not appear to happen with other widget types.
I don't normally develop for Python and it's been a long time since I last wrote any GLSL so do let me know if I've made any obvious mistakes.
Related PRs
Example
Here's an example of the kinds of things you can do with this effect:
and here's the config that created this: