Skip to content

Instantly share code, notes, and snippets.

@Koshimizu-Takehito
Koshimizu-Takehito / ContentView.swift
Created July 27, 2024 09:36
SwiftUI: Wallet Card Transition
import SwiftUI
struct Card: Identifiable, Hashable {
let id = UUID()
let creditID = UUID()
let colors: [Color]
let name: String
let number: String
}
@Matt54
Matt54 / PointLightsInsideContainerView.swift
Last active July 21, 2024 13:17
RealityKit extruded container view made of reflective and transparent materials. Points lights animate inside with their positions represented as spheres.
import RealityKit
import SwiftUI
struct PointLightsInsideContainerView: View {
@State private var rootEntity: Entity?
@State private var timer: Timer?
@State private var spherePositions: [String: SIMD3<Float>] = [:]
@State private var sphereTargetPositions: [String: SIMD3<Float>] = [:]
@State private var rotationAngle: Float = 0
@Koshimizu-Takehito
Koshimizu-Takehito / ContentView.swift
Created July 15, 2024 04:19
HierarchicalShapeStyle
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
TextSampleView(style: .foreground)
TextSampleView(style: .mint)
TextSampleView(style: linearGradient)
}
.font(.largeTitle)
@Koshimizu-Takehito
Koshimizu-Takehito / MazeObject.swift
Created July 7, 2024 04:38
穴掘り法(Aldous-Broder Algorithm)を使用した迷路生成ロジック
import SwiftUI
import Observation
struct ContentView: View {
@State private var model = MazeObject(width: 39, height: 39)
@State private var resetID = UUID()
@State private var disabled = false
var body: some View {
VStack {
@Matt54
Matt54 / GlowingSphere.swift
Created June 30, 2024 12:26
A blend of many spheres with varying opacity and size fading in and out
import RealityKit
import SwiftUI
struct GlowingSphere: View {
@State private var opacity: Float = 1.0
@State private var isForward: Bool = false
var body: some View {
GeometryReader3D { proxy in
RealityView { content in
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView(.vertical) {
ForEach(0..<1000) { i in
RoundedRectangle(cornerRadius: 24)
.fill(.blue)
.frame(height: 100)
.padding(.horizontal)
@Matt54
Matt54 / MorphingSphereRealityView.swift
Created June 20, 2024 23:49
A RealityView using a LowLevelMesh to produce a morphing sphere
import RealityKit
import SwiftUI
import GameplayKit
struct MorphingSphereRealityView: View {
@State private var currentEntity: Entity?
@State private var morphFactor: Float = 0.0
@State private var frameDuration: TimeInterval = 0.0
@State private var lastUpdateTime = CACurrentMediaTime()
@Matt54
Matt54 / AnimatingMaskedMeshView.swift
Created June 13, 2024 12:21
An animating mesh gradient view with an animating mask
import SwiftUI
struct AnimatingMaskedMeshView: View {
let referenceDate: Date = .now
@State private var mainPosition: CGPoint = .zero
@State private var positions: [CGPoint] = []
private let blurRadius = 20.0
private let alphaThreshold = 0.875
@stzn
stzn / The Swift Concurrency Migration Guide Data Race Safety.md
Last active July 5, 2024 21:33
Data Race Safety in The Swift Concurrency Migration Guide

データ競合安全

Swiftの基本的な概念について学び、データ競合のない並行コードを実現する方法を知りましょう。

原文 https://github.com/apple/swift-migration-guide/blob/main/Guide.docc/DataRaceSafety.md
更新日 2024/7/6(翻訳を最後に更新した日付)
ここまで反映 https://github.com/apple/swift-migration-guide/commit/24e31ffc589fefb42f08877878e689eb29b1644b

従来、可変状態(mutable state)は、細心の注意を払い、実行時の同期によって手動で保護する必要がありました。

@Koshimizu-Takehito
Koshimizu-Takehito / App.swift
Last active June 21, 2024 08:31
Hacker Text Effect - SwiftUI - iOS 16 & iOS 17
import SwiftUI
@main
struct App: SwiftUI.App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}