Skip to content

Instantly share code, notes, and snippets.

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

takehito Koshimizu-Takehito

🏝️
View GitHub Profile
@Koshimizu-Takehito
Koshimizu-Takehito / ContentView.swift
Created November 23, 2025 10:35
Split-screen mosaic shader for SwiftUI
import AVFoundation
import CoreImage
import SwiftUI
/// A sample view that plays a remote video and applies a controllable mosaic shader.
///
/// This view demonstrates how to:
/// - Pull video frames from `AVPlayer` using `AVPlayerItemVideoOutput`
/// - Render them in SwiftUI as a `CGImage`
/// - Apply a custom Metal-based mosaic effect using `ShaderLibrary`
@Koshimizu-Takehito
Koshimizu-Takehito / README.md
Created November 23, 2025 02:58 — forked from IsaacXen/README.md
(Almost) Every WWDC videos download links for aria2c.
#include <metal_stdlib>
#include <SwiftUI/SwiftUI.h>
using namespace metal;
// 画面の曲面歪みを適用する関数
// この関数は、CRTモニターの曲面ガラスによる画像の歪みをシミュレートします。
// UV座標(0.0〜1.0の正規化座標)を入力とし、中央からの距離に基づいて
// バレル歪み(barrel distortion)を適用します。これにより、画面の端が
// 外側に膨張するような効果が生まれ、レトロなCRTの視覚を再現します。
// - Parameters:
@Koshimizu-Takehito
Koshimizu-Takehito / GameOfLifeKernels.metal
Last active November 4, 2025 23:30
Conway's Game of Life(コンウェイのライフゲーム)
#include <metal_stdlib>
using namespace metal;
// ============================================================================
// Compute: 1 step of Game of Life
// ============================================================================
/**
* @brief Perform a single step update of Conway's Game of Life.
*
@Koshimizu-Takehito
Koshimizu-Takehito / FibonacciLayout.swift
Last active December 4, 2025 07:02
辺の比がフィボナッチ数の正方形になるように配置するLayoutプロトコル
import SwiftUI
struct FibonacciLayout: Layout {
struct Cache {
var fib: [Int128]
}
func makeCache(subviews: Subviews) -> Cache {
switch subviews.count {
case ...2:
@Koshimizu-Takehito
Koshimizu-Takehito / ColorSegmentedControl.swift
Last active May 5, 2025 14:12
A demo screen showcasing a custom color-based segmented control component.
import SwiftUI
// MARK: - Demo Screen
/// A demo screen showcasing a custom color-based segmented control component.
/// Displays a list of segments and shows the selected segment's value in a large, bold title.
struct ColorSegmentedControlDemoScreen: View {
/// The static list of selectable segments.
private static let demoItems: [ColorItem] = [
ColorItem(value: "Apple", color: .red),
@Koshimizu-Takehito
Koshimizu-Takehito / BadgeModel.swift
Created May 3, 2025 09:19
Displays the provided value inside a capsule‑shaped badge.
import Observation
/// An observable view‑model that drives a numeric badge.
///
/// `BadgeModel` keeps track of the current count (`number`) and the
/// badge’s visual appearance (`style`). It also exposes two derived
/// properties that make it easy to bind the model to SwiftUI controls:
///
/// * `slider` – Bridges the `Int`‐based `number` to floating‑point
/// controls such as `Slider`.
@Koshimizu-Takehito
Koshimizu-Takehito / StrokeModifier.swift
Last active April 27, 2025 02:34
ビューに枠線を引く
import SwiftUI
// MARK: - Demo Screen
/// A sample screen demonstrating three stacked stroke effects produced by
/// `StrokeModifier`.
/// Each call to `.stroke(_:width:)` adds an additional blurred outline,
/// resulting in a multi-layered border.
struct StrokeModifierDemoScreen: View {
var body: some View {
@Koshimizu-Takehito
Koshimizu-Takehito / OrbitingDotsLoadingView.swift
Last active June 15, 2025 19:36
Demonstrates `OrbitingDotsLoader` and lets you preview it at any built-in `ControlSize`.
import SwiftUI
// MARK: - Demo Screen
/// Demonstrates `OrbitingDotsLoadingView` and lets you preview it at any
/// built-in `ControlSize`.
///
/// The loader is centered, while the bottom `ControlSizePicker` writes
/// to `controlSize`, automatically propagating the value down the view
/// hierarchy through `.controlSize(_:)`.
import SwiftUI
struct ContentView: View {
var body: some View {
TextShape(sample)
.fill(.orange)
.stroke(.blue, lineWidth: 2)
}
var sample: AttributedString {