Replies: 1 comment 3 replies
-
Hi. ShapeStyles based on Shader, such as the ones created in this package can be used as Views: Because of this extension that's included in SwiftUI: |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @fwrs
Just wanted to ask if you know any other ways to call
[[ stitchable ]]
MSL
functions in SwiftUI other than these four methods:Abide either the colorEffect, layerEffect or the distortionEffect function signatures & then create
View
extensions which utilizes the filterEffect ...Create a struct which conforms to
ShapeStyle
,View
,Sendable
& call the shader function in thefunc resolve()
which is required for the struct to conform toShapeStyle
(The approach you used in your package).This approach has a small downside. The metal function is called in a method that returns
some ShapeStyle
& as the result, you don't get some advantages of a method which returnssome View
(Shader
doesn't conform toView
) ...So, in order to gain those advantages, you'd have to create another View struct & call the former
ShapeStyle
insidevar body
.Beta Was this translation helpful? Give feedback.
All reactions