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;
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) {
return length(point - center) - radius;
#include <metal_stdlib>
using namespace metal;
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) {
return length(point - center) - radius;
import SwiftUI
struct ContentView: View {
var body: some View {
WavingText()
.foregroundStyle(.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(hue: 220/360, saturation: 0.3, brightness: 0.9))
}
}
import SwiftUI
struct ContentView: View {
private var title: String {
Item.sample.title
}
private var message: String {
Item.sample.message
}
import SwiftUI
struct ContentView: View {
@State var isExpanded = [true] + Array(repeating: false, count: PageItem.samples.count)
var body: some View {
ZStack {
ForEach(1..<isExpanded.count, id: \.self) { offset in
let item = PageItem.samples[(offset-1) % PageItem.samples.count]
PageView(
import SwiftUI
struct ContentView: View {
@State var isExpanded = [true] + Array(repeating: false, count: 10)
var body: some View {
ZStack {
ForEach(1..<isExpanded.count, id: \.self) { offset in
CircleView(
color: .color(offset: offset),
@Koshimizu-Takehito
Koshimizu-Takehito / ColorMap.swift
Created February 11, 2025 07:01
色付きマップ
import SwiftUI
import MapKit
struct ContentView: View {
@State var position = MapCameraPosition.region(
MKCoordinateRegion(
center: CLLocationCoordinate2DMake(35.685175, 139.7528),
span: MKCoordinateSpan(latitudeDelta: 0.03, longitudeDelta: 0.03)
)
)
import SwiftUI
import MapKit
struct MonotoneMap: View {
@State var position = MapCameraPosition.region(
MKCoordinateRegion(
center: CLLocationCoordinate2DMake(35.685175, 139.7528),
span: MKCoordinateSpan(latitudeDelta: 0.03, longitudeDelta: 0.03)
)
)
@Koshimizu-Takehito
Koshimizu-Takehito / ShaderView.swift
Created February 11, 2025 04:35
MSLでパーティクル
import SwiftUI
struct ShaderView: View {
let name: String
private let start = Date()
var body: some View {
let shader = ShaderFunction(library: .default, name: name)
TimelineView(.animation) { context in
let seconds = context.date.timeIntervalSince(start)
@Koshimizu-Takehito
Koshimizu-Takehito / ReverseList.swift
Last active January 24, 2025 14:37
逆向きのリスト
import SwiftUI
struct Item: Identifiable, Hashable {
var id = UUID()
}
struct ContentView: View {
@State var items = [Item()]
var body: some View {