Skip to content

Instantly share code, notes, and snippets.

//
// SignatureAnimation.swift
// OpenSwiftUIAnimations
//
// Created by Amos Gyamfi on 11.5.2024.
//
import SwiftUI
struct SignatureAnimation: View {
@Koshimizu-Takehito
Koshimizu-Takehito / ContentView.swift
Created May 11, 2024 09:59
グラデーションアニメーション
import SwiftUI
extension [Color] {
static func rainbow(hue: Double = 0, count: Int) -> Self {
(0..<count).map { i in
var value = hue + Double(i) / Double(count)
value -= floor(value)
return Color(hue: value, saturation: 1/4, brightness: 1)
}
}
#include <metal_stdlib>
using namespace metal;
namespace JuliaSet {
/// HSV -> RGB
half3 hsv2rgb(half3 c) {
half3 rgb = clamp(abs(fmod(c.x * 6.0 + half3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
return c.z * mix(half3(1.0), rgb, c.y);
}
import SwiftUI
struct SqureFlowView: View {
@StateObject private var holder = SquresHolder()
var body: some View {
TimelineView(.animation) { timeline in
Canvas { context, size in
holder.update(at: timeline.date, in: size)
for item in holder.squre {
#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) {
@sebjvidal
sebjvidal / ViewController.swift
Created April 30, 2024 15:50
Apple Journal Calendar UI Demo
//
// ViewController.swift
// Journal-Calendar-Demo
//
// Created by Seb Vidal on 30/04/2024.
//
import UIKit
class ViewController: UIViewController {
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
@p-x9
p-x9 / create-xcframework.sh
Last active February 26, 2024 13:33
Create xcframework from Swift Package
set -Ceu
PACKAGE_DIR=$(
cd "$(dirname "$0")/.." || exit 1
pwd
)
cd "${PACKAGE_DIR}" || exit 1
DERIVED_DATA_PATH=".build"
OUTPUT="XCFrameworks"
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
@ole
ole / swift-has-feature.sh
Last active May 12, 2024 22:20
swift-list-feature: List Swift compiler upcoming and experimental feature flags. ★ swift-has-feature: Check if a given compiler knows a specific feature flag, and whether it's an upcoming or experimental flag.
#!/bin/zsh
# Test if the Swift compiler knows about a particular language feature.
#
# Usage:
#
# swift-has-feature [--swift SWIFT_PATH] [--language-version LANGUAGE_VERSION] FEATURE
#
# The feature should be an upcoming or experimental language feature,
# such as `"StrictConcurrency"` or `"ExistentialAny"`.