Skip to content

Instantly share code, notes, and snippets.

View Koshimizu-Takehito's full-sized avatar
🏝️

takehito Koshimizu-Takehito

🏝️
View GitHub Profile
#include <metal_stdlib>
using namespace metal;
namespace SmoothMin2d {
float smoothMin(float x1, float x2, float k) {
float h = clamp(0.5 - 0.5 * (x2 - x1) / k, 0.0, 1.0);
return mix(x1, x2, h) - k * h * (1.0 - h);
}
float circleSDF(float2 point, float2 center, float radius) {
import SwiftUI
struct LoadingView: View {
@State var theta: Double = 0
let radius: Double = 60
var body: some View {
ZStack {
ForEach(0..<8) { index in
let offset = ((2 * .pi) * Double(index)) / 8
import SwiftUI
struct ContentView: View {
@State var theta: Double = 0
let radius: Double = 60
let colors: [Color] = [.purple, .red, .yellow, .blue, .green]
var body: some View {
ZStack {
ForEach(Array(colors.enumerated()), id: \.offset) { offset, style in
@Koshimizu-Takehito
Koshimizu-Takehito / OscillatingEffect.swift
Last active September 17, 2023 05:16
ホームスクリーンのアイコンのブルブルするやつ
import SwiftUI
let symbols = [
"pencil",
"trash",
"folder",
"camera",
"photo",
"clock",
"arrow.right.circle.fill",
@Koshimizu-Takehito
Koshimizu-Takehito / CustomAnimationGraph.swift
Created July 22, 2023 15:43
CustomAnimationをグラフで描画
import SwiftUI
struct AnimationGridView: View {
@State
private var id: UUID = .init()
var body: some View {
ZStack {
Color(.systemBackground)
VStack {
@Koshimizu-Takehito
Koshimizu-Takehito / PhisicsLoadingView.swift
Last active July 22, 2023 03:34
おしゃれなローディングアニメーション
// Thanks to @Ren_yello
// https://twitter.com/ren_yello/status/1681856952090112000?s=61&t=SNv1ZCU_S3Y8TobPv4MBww
import SwiftUI
struct PhisicsLoadingView: View {
@State private var color: CGColor = .black
@State private var angle1: CGFloat = .pi/2
@State private var angle2: CGFloat = .pi/2
@State private var angle3: CGFloat = .pi/2
@Koshimizu-Takehito
Koshimizu-Takehito / LoadingSquares.swift
Last active July 19, 2023 23:03
おしゃれなローディングアニメーション
// Thanks to @Ren_yello
// https://twitter.com/ren_yello/status/1681556136682741762?s=61&t=SNv1ZCU_S3Y8TobPv4MBww
import SwiftUI
struct ContentView: View {
var body: some View {
LoadingSquares()
}
}
@Koshimizu-Takehito
Koshimizu-Takehito / LoadingCircles.swift
Created July 18, 2023 23:40
おしゃれなローディングアニメーション
import SwiftUI
// Thanks to @Ren_yello
// https://twitter.com/ren_yello/status/1681135824145113089?s=61&t=Z69bUaia8ogjDHp-N7Xvvg
struct ContentView: View {
@State var ratio: Double = 0
@State var angle: CGFloat = 0
@State var delta: CGFloat = 0
var body: some View {
@Koshimizu-Takehito
Koshimizu-Takehito / SegmentedControl.swift
Created July 17, 2023 09:52
カスタムなセグメントコントロール
import SwiftUI
struct ContentView: View {
@State var selectedIndex = 0
let options = ["Apple", "Orange", "Muscat"]
let colors: [Color] = [.red, .orange, .green]
var body: some View {
VStack {
SegmentedControl(selectedIndex: $selectedIndex, options: options, colors: colors)
@Koshimizu-Takehito
Koshimizu-Takehito / メタボールっぽいやつ2.swift
Created May 7, 2023 03:23
メタボールっぽいやつ2.swift
import SwiftUI
import Combine
extension ParticlesView {
init(count: Int) {
self.init(scales: Array(repeating: false, count: count))
}
}
struct ParticlesView: View {