Kaynağa Gözat

Finished badge drawing procedures.

Admin 4 yıl önce
ebeveyn
işleme
f70a328fb1

+ 18 - 2
Landmarks/DrawingPathsAndShapes.xcodeproj/project.pbxproj

@@ -7,6 +7,10 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		845967802543064F008C197E /* Badge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8459677F2543064F008C197E /* Badge.swift */; };
+		8459678325431F38008C197E /* BadgeBackground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8459678225431F38008C197E /* BadgeBackground.swift */; };
+		8459678625431F94008C197E /* BadgeSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8459678525431F94008C197E /* BadgeSymbol.swift */; };
+		84596789254323E2008C197E /* RotatedBadgeSymbol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84596788254323E2008C197E /* RotatedBadgeSymbol.swift */; };
 		B7310DD1229F6839001079B9 /* HexagonParameters.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7310DD0229F6839001079B9 /* HexagonParameters.swift */; };
 		B7394866229F194000C47603 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7394865229F194000C47603 /* AppDelegate.swift */; };
 		B7394868229F194000C47603 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7394867229F194000C47603 /* SceneDelegate.swift */; };
@@ -37,7 +41,11 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
-		27FFE5444DA58085F4325C68 /* LICENSE.txt */ = {isa = PBXFileReference; includeInIndex = 1; path = LICENSE.txt; sourceTree = "<group>"; };
+		27FFE5444DA58085F4325C68 /* LICENSE.txt */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE.txt; sourceTree = "<group>"; };
+		8459677F2543064F008C197E /* Badge.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Badge.swift; sourceTree = "<group>"; };
+		8459678225431F38008C197E /* BadgeBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeBackground.swift; sourceTree = "<group>"; };
+		8459678525431F94008C197E /* BadgeSymbol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BadgeSymbol.swift; sourceTree = "<group>"; };
+		84596788254323E2008C197E /* RotatedBadgeSymbol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RotatedBadgeSymbol.swift; sourceTree = "<group>"; };
 		B7310DD0229F6839001079B9 /* HexagonParameters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexagonParameters.swift; sourceTree = "<group>"; };
 		B7394862229F194000C47603 /* Landmarks.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Landmarks.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		B7394865229F194000C47603 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -67,7 +75,7 @@
 		B73948A0229F2E1F00C47603 /* LandmarkList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LandmarkList.swift; sourceTree = "<group>"; };
 		B73948A2229F3E2200C47603 /* charleyrivers.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = charleyrivers.jpg; sourceTree = "<group>"; };
 		B7D2AAC4229F4D7C0061E5F5 /* UserData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserData.swift; sourceTree = "<group>"; };
-		B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */ = {isa = PBXFileReference; name = SampleCode.xcconfig; path = ../Configuration/SampleCode.xcconfig; sourceTree = "<group>"; };
+		B8A4CAA78D6B798B07B45529 /* SampleCode.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = SampleCode.xcconfig; path = ../Configuration/SampleCode.xcconfig; sourceTree = "<group>"; };
 		C4E4AAA0C4E4035000000001 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
@@ -125,6 +133,10 @@
 				B7394870229F194200C47603 /* LaunchScreen.storyboard */,
 				B7394873229F194200C47603 /* Info.plist */,
 				B739486D229F194200C47603 /* Preview Content */,
+				8459677F2543064F008C197E /* Badge.swift */,
+				8459678525431F94008C197E /* BadgeSymbol.swift */,
+				84596788254323E2008C197E /* RotatedBadgeSymbol.swift */,
+				8459678225431F38008C197E /* BadgeBackground.swift */,
 			);
 			path = Landmarks;
 			sourceTree = "<group>";
@@ -270,12 +282,16 @@
 			buildActionMask = 2147483647;
 			files = (
 				B7394882229F28B900C47603 /* Data.swift in Sources */,
+				845967802543064F008C197E /* Badge.swift in Sources */,
 				B7394866229F194000C47603 /* AppDelegate.swift in Sources */,
 				B739487A229F1B3F00C47603 /* CircleImage.swift in Sources */,
 				B739487C229F1B6800C47603 /* MapView.swift in Sources */,
 				B7310DD1229F6839001079B9 /* HexagonParameters.swift in Sources */,
 				B73948A1229F2E1F00C47603 /* LandmarkList.swift in Sources */,
+				8459678625431F94008C197E /* BadgeSymbol.swift in Sources */,
+				84596789254323E2008C197E /* RotatedBadgeSymbol.swift in Sources */,
 				B7394868229F194000C47603 /* SceneDelegate.swift in Sources */,
+				8459678325431F38008C197E /* BadgeBackground.swift in Sources */,
 				B739486A229F194000C47603 /* LandmarkDetail.swift in Sources */,
 				B739489F229F2D9700C47603 /* LandmarkRow.swift in Sources */,
 				B7D2AAC5229F4D7C0061E5F5 /* UserData.swift in Sources */,

+ 8 - 0
Landmarks/DrawingPathsAndShapes.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IDEDidComputeMac32BitWarning</key>
+	<true/>
+</dict>
+</plist>

BIN
Landmarks/DrawingPathsAndShapes.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate


+ 6 - 0
Landmarks/DrawingPathsAndShapes.xcodeproj/xcuserdata/admin.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Bucket
+   uuid = "442118A6-D5B6-496A-8BC4-4AB0D5399D33"
+   type = "1"
+   version = "2.0">
+</Bucket>

+ 14 - 0
Landmarks/DrawingPathsAndShapes.xcodeproj/xcuserdata/admin.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>SchemeUserState</key>
+	<dict>
+		<key>Landmarks.xcscheme_^#shared#^_</key>
+		<dict>
+			<key>orderHint</key>
+			<integer>0</integer>
+		</dict>
+	</dict>
+</dict>
+</plist>

+ 41 - 0
Landmarks/Landmarks/Badge.swift

@@ -0,0 +1,41 @@
+//
+//  Badge.swift
+//  Landmarks
+//
+//  Created by Admin on 23.10.2020.
+//  Copyright © 2020 Apple. All rights reserved.
+//
+
+import SwiftUI
+
+struct Badge: View {
+    static let rotationCount = 8
+    
+    var badgeSymbols: some View {
+        ForEach(0..<Badge.rotationCount) { i in
+            RotatedBadgeSymbol(
+                angle: .degrees(Double(i) / Double(Badge.rotationCount)) * 360.0
+            )
+        }
+        .opacity(0.5)
+    }
+    
+    var body: some View {
+        ZStack {
+            BadgeBackground()
+            
+            GeometryReader { geometry in
+                self.badgeSymbols
+                    .scaleEffect(1.0 / 4.0, anchor: .top)
+                    .position(x: geometry.size.width / 2.0, y: (3.0 / 4.0) * geometry.size.height)
+            }
+        }
+        .scaledToFit()
+    }
+}
+
+struct Badge_Previews: PreviewProvider {
+    static var previews: some View {
+        Badge()
+    }
+}

+ 62 - 0
Landmarks/Landmarks/BadgeBackground.swift

@@ -0,0 +1,62 @@
+//
+//  BadgeBackground.swift
+//  Landmarks
+//
+//  Created by Admin on 23.10.2020.
+//  Copyright © 2020 Apple. All rights reserved.
+//
+
+import SwiftUI
+
+struct BadgeBackground: View {
+    var body: some View {
+        GeometryReader { geometry in
+            Path { path in
+                var width: CGFloat = min(geometry.size.width, geometry.size.height)
+                let height = width
+                let xScale: CGFloat = 0.832
+                let xOffset = (width * (1.0 - xScale)) / 2.0
+                width *= xScale
+                path.move(
+                    to: CGPoint(
+                        x: xOffset + width * 0.95,
+                        y: height * (0.20 + HexagonParameters.adjustment)
+                    )
+                )
+                
+                HexagonParameters.points.forEach {
+                    path.addLine(
+                        to: .init(
+                            x: xOffset + width * $0.useWidth.0 * $0.xFactors.0,
+                            y: height * $0.useHeight.0 * $0.yFactors.0
+                        )
+                    )
+                    
+                    path.addQuadCurve(
+                        to: .init(
+                            x: xOffset + width * $0.useWidth.1 * $0.xFactors.1,
+                            y: height * $0.useHeight.1 * $0.yFactors.1
+                        ),
+                        control: .init(
+                            x: xOffset + width * $0.useWidth.2 * $0.xFactors.2,
+                            y: height * $0.useHeight.2 * $0.yFactors.2
+                        )
+                    )
+                }
+            }
+            .fill(LinearGradient(
+                gradient: .init(colors: [Self.gradientStart, Self.gradientEnd]),
+                startPoint: .init(x: 0.5, y: 0),
+                endPoint: .init(x: 0.5, y: 0.6)
+            ))
+        }
+    }
+    static let gradientStart = Color(red: 239.0 / 255, green: 120.0 / 255, blue: 221.0 / 255)
+    static let gradientEnd = Color(red: 239.0 / 255, green: 172.0 / 255, blue: 120.0 / 255)
+}
+
+struct BadgeBackground_Previews: PreviewProvider {
+    static var previews: some View {
+        BadgeBackground()
+    }
+}

+ 50 - 0
Landmarks/Landmarks/BadgeSymbol.swift

@@ -0,0 +1,50 @@
+//
+//  BadgeSymbol.swift
+//  Landmarks
+//
+//  Created by Admin on 23.10.2020.
+//  Copyright © 2020 Apple. All rights reserved.
+//
+
+import SwiftUI
+
+struct BadgeSymbol: View {
+    let symbolcolor = Color(red: 79.0/255, green: 79.0/255, blue: 191.0/255)
+    
+    var body: some View {
+        GeometryReader{ geometry in
+            Path{ path in
+                let width = min(geometry.size.width, geometry.size.height)
+                let height = width * 0.75
+                let spacing = width * 0.030
+                let middle = width / 2
+                let topWidth = 0.226 * width
+                let topHeight = 0.488 * height
+                
+                path.addLines([
+                    CGPoint(x: middle, y: spacing),
+                    CGPoint(x: middle-topWidth, y: topHeight - spacing),
+                    CGPoint(x: middle, y:topHeight / 2 + spacing),
+                    CGPoint(x: middle + topWidth, y: topHeight - spacing),
+                    CGPoint(x: middle, y: spacing)
+                ])
+                
+                path.move(to: CGPoint(x: middle, y: topHeight/2 + spacing*3))
+                path.addLines([
+                    CGPoint(x: middle-topWidth, y: topHeight+spacing),
+                    CGPoint(x: spacing, y: height-spacing),
+                    CGPoint(x: width-spacing, y: height-spacing),
+                    CGPoint(x: middle+topWidth, y: topHeight+spacing),
+                    CGPoint(x: middle, y: topHeight/2 + spacing*3)
+                ])
+            }
+            .fill(symbolcolor)
+        }
+    }
+}
+
+struct BadgeSymbol_Previews: PreviewProvider {
+    static var previews: some View {
+        BadgeSymbol()
+    }
+}

+ 25 - 0
Landmarks/Landmarks/RotatedBadgeSymbol.swift

@@ -0,0 +1,25 @@
+//
+//  RotatedBadgeSymbol.swift
+//  Landmarks
+//
+//  Created by Admin on 23.10.2020.
+//  Copyright © 2020 Apple. All rights reserved.
+//
+
+import SwiftUI
+
+struct RotatedBadgeSymbol: View {
+    let angle: Angle
+    
+    var body: some View {
+        BadgeSymbol()
+            .padding(-60)
+            .rotationEffect(angle, anchor: .bottom)
+    }
+}
+
+struct RotatedBadgeSymbol_Previews: PreviewProvider {
+    static var previews: some View {
+        RotatedBadgeSymbol(angle: .init(degrees: 5))
+    }
+}