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

Create SwiftUI View extensions to apply each shader more easily #15

Open
twostraws opened this issue Nov 29, 2023 · 1 comment
Open
Labels
good first issue Good for newcomers

Comments

@twostraws
Copy link
Owner

The goal here is to make the shaders easily to apply by wrapping them in View extensions. So, rather than writing this:

Image(systemName: "figure.walk.circle")
    .font(.system(size: 300))
    .colorEffect(
        ShaderLibrary.checkerboard(
            .color(.red),
            .float(50)
        )
    )

Users might* instead write this:

Image(systemName: "figure.walk.circle")
    .font(.system(size: 300))
    .checkerboardEffect(size: 50, replacement: .red)

I've put the asterisk next to "might" because that's just a suggestion for the spelling. Other options that come to mind:

  • .checkerboard() <-- Might mean some shaders clash with other modifiers?
  • .infernoEffect(.checkerboard(size: 50, replacement: .red)) <-- uses enum associated values, and means we have only one top-level View modifier rather than one for each shader.

Two tips:

  1. You don't need to convert them all. In fact, it's better to convert a small number at a time then commit that change, to avoid clashes with other developers.
  2. You're welcome to submit other API naming ideas – I'd rather have a discussion about it and reach a consensus than just dive in with the first option that comes to mind 🙂

Thank you!

@gorpello
Copy link

gorpello commented Oct 8, 2024

Hi @twostraws, Thank you for all the work on Inferno! I’m interested in contributing!

I wanted to check on the current status of this – have there been any decisions around the naming convention for the new extensions?

Looking at the code, thanks to the @daprice contribution 🙌, it seems like there’s already an extension for the variableBlur shader. I’m curious about your thoughts on the naming convention used there. Would you prefer something more uniform across the board? For example, I’d suggest including "Inferno" in all the ViewModifier names (e.g., infernoCheckerboardEffect, infernoVariableBlur, etc.), to avoid potential conflicts with existing or future SwiftUI modifiers.

Thanks again, and I’m happy to help!

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

No branches or pull requests

2 participants