Last active
March 3, 2024 15:09
-
-
Save DarrenHurst/627573b8b12bb8f4a9d56fe11373f1e1 to your computer and use it in GitHub Desktop.
SwiftUIHop WonderFile002
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Bunny.swift | |
// Designer | |
// | |
// Created by Darren Hurst on 2024-03-02. | |
// | |
import Foundation | |
import SwiftUI | |
import OFCore | |
struct WonderFile002: View { | |
@State var animate: Bool = false | |
var body: some View { | |
VStack{ | |
ZStack { | |
EggShape().fill(.cyan).frame(width: 100, height: 200) | |
EggShape().stroke(.black).frame(width: 100, height: 200) | |
.background(LineShape() | |
.stroke(.black) | |
.rotationEffect(Angle(degrees: 115.0)) | |
.transformEffect(CGAffineTransform(translationX: 1.0, y: -20.3)) | |
.mask(EggShape()) | |
.foregroundColor(.blue) | |
) | |
Image(systemName: "star.fill") | |
.transformEffect(CGAffineTransform(a: 0.0, b: 1.0, c: 1.0, d: 1.0, tx: 1.0, ty: 1.0)) | |
.offset(x:-15, y:-10).opacity(0.3) | |
Image(systemName: "star.fill") | |
.transformEffect(CGAffineTransform(a: 1.0, b: 0, c: 1.0, d: 1.0, tx: 1.0, ty: 1.0)) | |
.offset(x:0, y:-50).opacity(0.3) | |
} | |
.onAppear(){ | |
animate.toggle() | |
} | |
.onTapGesture(){ | |
animate.toggle() | |
} | |
//.rotationEffect(Angle(degrees: 188.0)) | |
} | |
.background(Config().background) | |
.background(Rectangle()) | |
} | |
} | |
struct WonderFile002Preview: PreviewProvider { | |
static var previews: some View { | |
WonderFile002() | |
} | |
} | |
struct EggShape: Shape { | |
func path(in rect: CGRect) -> Path { | |
let width = 100.0 | |
let height = 150.0 | |
var path = Path() | |
path.addEllipse(in: CGRect(x: width * 0.2, y: height * 0.2, width: width * 0.6, height: height * 0.6)) | |
return path | |
} | |
} | |
struct LineShape: Shape { | |
func path(in rect: CGRect) -> Path { | |
var path = Path() | |
path.move(to: CGPoint(x: rect.minX, y: rect.minY)) | |
path.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY)) | |
return path | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Anyone remember these plastic snap eggs.. oh my goodness.