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

Light effects custom functions #12

Merged

Conversation

thomas-advantitge
Copy link
Contributor

This PR adds support for color functions in two ways:

  1. In the Type dropdown next to "Color ramp" and "Image". The function should return an RGBA tuple.
  2. The "Custom expression" output which was already there as a placeholder. The function should return a number between 0 and 1 which will be used to get the color of the color ramp or the pixel in the color image.

Example of how it can be used to add color animations in a bit more dynamic way than creating 2D images for the Image type:

# note: `if` conditions for readability, could be optimized in 1 line of math
def fade_sorted(frame, time_fraction, drone_index, formation_index, position, drone_count):
    factor = min(max(drone_count * (1.1 * time_fraction - formation_index / drone_count), 0.0), 1.0)
    if formation_index >= 112:
        return factor * 1.0
    if formation_index % 2 == 0:
        return 0.66 * factor
    return 0.33 * factor
example-color-functions.mp4

@CLAassistant
Copy link

CLAassistant commented Feb 13, 2024

CLA assistant check
All committers have signed the CLA.

@ntamas ntamas self-assigned this Feb 13, 2024
@ntamas
Copy link
Member

ntamas commented Feb 14, 2024

This looks awesome, thanks a lot! I'm going through the PR soon, stay tuned.

@ntamas ntamas merged commit 32417cc into skybrush-io:main Mar 4, 2024
2 checks passed
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.

3 participants