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

Add linear_gradient effect #435

Merged
merged 1 commit into from Jan 16, 2023

Conversation

nullbuilds
Copy link
Contributor

@nullbuilds nullbuilds commented Dec 25, 2022

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:
example

and here's the config that created this:

#config_version=5

window:
  width: 800
  height: 600
  title: Gradient Showcase

displays:
  window:
    width: 800
    height: 600
  text_display:
    width: 800
    height: 150
  rectangle_display:
    width: 800
    height: 600

slide_player:
  init_done:
    main_slide:
      target: window
    text_slide:
      target: text_display
    rectangle_slide:
      target: rectangle_display

slides:
  main_slide:
    background_color: ff5733ff
    widgets:
      - type: display
        width: 800
        height: 150
        source_display: text_display
        effects:
          - type: linear_gradient
            angle: 135
            color_stops:
              "0.2": 00ffffff
              "0.5": ff00ffff
              "0.8": ffff00ff
      - type: display
        width: 800
        height: 600
        source_display: rectangle_display
        effects:
          - type: linear_gradient
            color_stops:
              "0.0": 5d3fd3ff
              "1.0": 0000ff1c
  text_slide:
    background_color: 00000000
    widgets:
      - type: text
        text: Hello, World!
        font_size: 125
        anchor_x: center
        anchor_y: center
  rectangle_slide:
    background_color: 00000000
    widgets:
      - type: rectangle
        width: 800
        height: 600

Adds a new linear_gradient effect for the display widget. This initial
version of the effect allows for multiple color stops and custom angle.
@nullbuilds
Copy link
Contributor Author

Looks like the SDist step is failing in the build due to an unmet dependency. Is this expected? I didn't changed any dependencies so I assume this is unrelated to my changes:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libunwind-14-dev : Breaks: libunwind-dev but 1.3.2-2build2 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
Error: Process completed with exit code 100.

@toomanybrians toomanybrians merged commit cacca82 into missionpinball:dev Jan 16, 2023
@toomanybrians
Copy link
Member

Thanks for this! I fixed the SDist issues (not related to anything you did here) and merged this in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants