Skip to content

Instantly share code, notes, and snippets.

@Koshimizu-Takehito
Koshimizu-Takehito / TileAnimation2.swift
Created January 18, 2025 09:25
ViewのIdentity を意識してアニメーション素振り
import SwiftUI
// MARK: - Model
@MainActor
@Observable
final class Model {
var angles: [[Angle]]
init(row: Int, column: Int) {
angles = (0..<row).map { _ in
import React, { useState } from 'react';
import { Pressable, View } from 'react-native';
import Animated, { css } from 'react-native-reanimated';
export default function Wave() {
const [clickLocation, setClickLocation] = useState({ x: -1, y: -1 });
const dots = Array.from({ length: 323 });
const size = 19;
const color = `rgb(${Math.random() * 255}, ${Math.random() * 255}, ${Math.random() * 255})`
import React, { useState } from 'react';
import { Pressable, Text } from 'react-native';
import Animated, { css } from 'react-native-reanimated';
export default function ParticleButton() {
const [pressed, setPressed] = useState(false);
const [showParticles, setShowParticles] = useState(false);
return (
<Pressable
@Koshimizu-Takehito
Koshimizu-Takehito / SpiralShader.metal
Last active February 11, 2025 23:41
シェーダー関数で螺旋
#include <metal_stdlib>
using namespace metal;
[[ stitchable ]] half4 spiral(
float2 position,
half4 color,
float4 box,
float scale
) {
position = position - box.zw/2;
@Koshimizu-Takehito
Koshimizu-Takehito / Spiral.swift
Created December 31, 2024 06:08
アルキメデスのらせん
import SwiftUI
struct ContentView: View {
@State var start = Date()
var body: some View {
TimelineView(.animation) { context in
let time = context.date.timeIntervalSince(start) / 120
let rotation = 0.8 + 0.2 * abs((cos(.pi * time) + 1.0) / 2.0)
Canvas { context, size in
@Koshimizu-Takehito
Koshimizu-Takehito / TileAnimation.swift
Created November 29, 2024 07:43
アニメーション素振り
import SwiftUI
// MARK: - Model
@MainActor
@Observable
final class Model {
var rotations: [[Int]]
init(row: Int, column: Int) {
rotations = (0..<row).map { _ in
import SwiftUI
struct ContentView: View {
@StateObject private var viewModel = RectsViewModel()
var body: some View {
GeometryReader { geometry in
TimelineView(.animation) { timeline in
Canvas {context, size in
let rects = viewModel.rects
@Koshimizu-Takehito
Koshimizu-Takehito / DynamicTypeSize.swift
Created October 20, 2024 10:19
ダイナミックタイプを利用した場合の標準フォントのスケール
import SwiftUI
#Preview {
@Previewable @State var value: Double = 3.0
VStack {
SampleView()
.environment(\.dynamicTypeSize, .allCases[Int(value)])
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .trailing)
.contentTransition(.numericText())
Text("\(DynamicTypeSize.allCases[Int(value)])")
import SwiftUI
struct ContentView: View {
@Environment(\.colorScheme) var scheme
private let date = Date()
private let colors = [Color.green, .pink, .blue, .orange, .purple]
private let titles = ["NEON", "GLOW", "LIGHT", "SHINE", "BRIGHT"]
var body: some View {
TimelineView(.animation) { context in