Skip to content

Conversation

@yakupcaglan
Copy link

Summary

This PR adds SwiftUI View extensions for all Simple Transformation shaders, making them easier to use.

Addresses #15

Changes

Added View extensions for:

  • .checkerboard(size:color:)
  • .emboss(strength:)
  • .gradientFill()
  • .infrared()
  • .interlace(width:color:strength:)
  • .invertAlpha(replacement:)
  • .passthrough()
  • .rainbowNoise(time:)
  • .recolor(to:)

Usage Example

Before (using shader directly):

Image("photo")
    .colorEffect(
        InfernoShaderLibrary.checkerboard(
            .color(.blue),
            .float(10)
        )
    )

After (using View extension):

Image("photo")
    .checkerboard(size: 10, color: .blue)

Note

If this PR is approved, I'd be happy to update the README with documentation for these new View extensions.

Added SwiftUI View extensions to make shader usage more convenient:

- Checkerboard: .checkerboard(size:color:)
- Emboss: .emboss(strength:)
- GradientFill: .gradientFill()
- Infrared: .infrared()
- Interlace: .interlace(width:color:strength:)
- InvertAlpha: .invertAlpha(replacement:)
- Passthrough: .passthrough()
- RainbowNoise: .rainbowNoise(time:)
- Recolor: .recolor(to:)

This addresses issue twostraws#15 by providing easier API for applying shaders.
Copy link

@EnesKaraosman EnesKaraosman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extensions, could you please update the docs as well 🚀

@twostraws
Copy link
Owner

Hello! This looks fantastic. As long as the underlying Metal shaders have not changed – and it looks like they have not – I think we should press ahead with this. Are you happy to update the docs?

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