Skip to content

Commit

Permalink
re-adding WallSticky to fix git issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlintott committed Nov 17, 2021
1 parent 916a649 commit 1ef7f07
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Molt.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
CF360188273C2FC3006B6BA7 /* NSManagedObjectContext-extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF360187273C2FC2006B6BA7 /* NSManagedObjectContext-extension.swift */; };
CF36018A273C3142006B6BA7 /* PersistenceMolt.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF360189273C3142006B6BA7 /* PersistenceMolt.swift */; };
CF36018E273C5370006B6BA7 /* ParallaxImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF36018D273C5370006B6BA7 /* ParallaxImage.swift */; };
CF47FBE327458A4A0045CA84 /* WallSticky.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF47FBE227458A4A0045CA84 /* WallSticky.swift */; };
CF59769F2742EF0100119099 /* Marketing.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF59769E2742EF0100119099 /* Marketing.swift */; };
CF8B11AC2735826B00579F46 /* MoltApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF8B11AB2735826B00579F46 /* MoltApp.swift */; };
CF8B11AE2735826B00579F46 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CF8B11AD2735826B00579F46 /* ContentView.swift */; };
Expand Down Expand Up @@ -90,6 +91,7 @@
CF360187273C2FC2006B6BA7 /* NSManagedObjectContext-extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSManagedObjectContext-extension.swift"; sourceTree = "<group>"; };
CF360189273C3142006B6BA7 /* PersistenceMolt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistenceMolt.swift; sourceTree = "<group>"; };
CF36018D273C5370006B6BA7 /* ParallaxImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParallaxImage.swift; sourceTree = "<group>"; };
CF47FBE227458A4A0045CA84 /* WallSticky.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WallSticky.swift; sourceTree = "<group>"; };
CF59769E2742EF0100119099 /* Marketing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Marketing.swift; sourceTree = "<group>"; };
CF8B11A82735826B00579F46 /* Molt.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Molt.app; sourceTree = BUILT_PRODUCTS_DIR; };
CF8B11AB2735826B00579F46 /* MoltApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoltApp.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -263,6 +265,7 @@
CFA1CA0827371E790025EAEF /* InteractiveStickyView.swift */,
CF8B11DB2735A2D000579F46 /* StickyViewDemo.swift */,
D59178932737D96200F9C11A /* StickyViewWithData.swift */,
CF47FBE227458A4A0045CA84 /* WallSticky.swift */,
);
path = Sticky;
sourceTree = "<group>";
Expand Down Expand Up @@ -442,6 +445,7 @@
CFA9CAD227382A390006C424 /* MoltData.xcdatamodeld in Sources */,
CFA9CB2127385AF30006C424 /* MainView.swift in Sources */,
91CBF0C62735857700C4E8BC /* StartPage.swift in Sources */,
CF47FBE327458A4A0045CA84 /* WallSticky.swift in Sources */,
CFA9CB1527382EF60006C424 /* MoltSession+example.swift in Sources */,
91CBF0D02735B3FC00C4E8BC /* ParallaxEffect.swift in Sources */,
CF0814B82736B09B00D7E562 /* StrokeStyle+dashed.swift in Sources */,
Expand Down
52 changes: 52 additions & 0 deletions Molt/View/Sticky/WallSticky.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//
// WallSticky.swift
// Molt
//
// Created by Ryan Lintott on 2021-11-06.
//

import SwiftUI

struct WallSticky: Identifiable, Hashable {
let id: Int
let color: Color
var x: CGFloat
var y: CGFloat
var curvePhase: CGFloat

init(id: Int, color: Color, x: CGFloat, y: CGFloat, curvePhase: CGFloat = CGFloat.random(in: 0...1)) {
self.id = id
self.color = color
self.x = x
self.y = y
self.curvePhase = curvePhase
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}

extension Array where Element == WallSticky {
static func rainbow(count: Int, aspectRatio: CGFloat = 1) -> Self {
let positions = Array<Int>(0..<count).map {
CGPoint(x: CGFloat.random(in: 0...1), y: CGFloat($0) / CGFloat(count))
}
.shuffled()

let colors = Color.stickyRainbow(count: count)

return zip(colors, positions)
.enumerated()
.map {
WallSticky(
id: $0,
color: $1.0,
x: $1.1.x,
y: $1.1.y
)
}
.sorted(by: { lhs, rhs in
lhs.y > rhs.y
})
}
}

0 comments on commit 1ef7f07

Please sign in to comment.