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 / 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 October 26, 2025 14:21
辺の比がフィボナッチ数の正方形になるように配置する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 {
@Koshimizu-Takehito
Koshimizu-Takehito / VisualEffect3.swift
Created April 12, 2025 10:59
visualEffectモディファイア
import SwiftUI
struct ContentView: View {
var body: some View {
GeometryReader { geometry in
let scrollViewFrame = geometry.frame(in: .local)
ScrollView {
ForEach(0..<1000) { offset in
RowContent(offset: offset, scrollViewFrame: scrollViewFrame)
}
@Koshimizu-Takehito
Koshimizu-Takehito / MazeGenerator.swift
Last active June 12, 2025 09:01
迷路生成ロジック
import Combine
import Foundation
// MARK: - MazeGenerator (Model)
/// An actor that generates a maze using a depth-first search (DFS) based approach.
/// 深さ優先探索 (DFS) ベースのアルゴリズムを用いて迷路を生成する。
///
/// This actor provides an async stream of snapshots (`MazeGenerator.Snapshot`) so that observers
/// can track the maze's state and generation progress in real time.
@Koshimizu-Takehito
Koshimizu-Takehito / nvironmentValuesSample2.swift
Created March 29, 2025 08:44
EnvironmentValuesが大域変数ではないことを示すサンプルコード2
import SwiftUI
extension EnvironmentValues {
@Entry var customStringValue = "Goodbye, world!"
}
struct ContentView: View {
var body: some View {
RepRepresentable()
.environment(\.customStringValue, "Hello, world!")