title: Hover effect for SwiftUI Shapes for the mac
body: <p>I'd like to create a hover effect for SwiftUI shapes for the mac which takes the actual shape into account.
  The <code>onHover</code> modifier is not good because it fires when the mouse enters the frame, rather than the SwiftUI <code>Shape</code>. <code>hoverEffect</code> is not available for the Mac.</p>
  <p>How to create a hover effect that takes the underlying shape into account?</p>
  <p><a href="https://i.stack.imgur.com/wAxen.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wAxen.gif" alt="enter image description here" /></a></p>
  <pre class="lang-swift prettyprint-override"><code>import SwiftUI
  
  struct HoverViewModifier : ViewModifier {
      @State private var hovered = false
      func body(content: Content) -&gt; some View {
          content
              .foregroundColor(hovered ? .accentColor : .primary)
              .onHover { isHovered in
                  self.hovered = isHovered
              }
      }
  }
  
  struct MyStar : Shape {
      func path(in rect : CGRect) -&gt; Path {
          let points = [
              (50, 0), (61, 33), (97, 34), (69, 56), (79, 90), (50, 70), (20, 90), (30, 56), ( 2, 34), (38, 33)
          ].map { (x : CGFloat, y : CGFloat) in
              CGPoint(x: x * rect.width / 100, y: y * rect.height / 100)
          }
          var path = Path()
          path.addLines(points)
          return path
      }
  }
  
  struct ContentView : View {
      var body: some View {
          HStack {
              Circle().modifier(HoverViewModifier())
              MyStar().modifier(HoverViewModifier())
          }.frame(width: 200, height: 100)
      }
  }
  
  struct ContentView_Previews: PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  </code></pre>