Skip to content

Instantly share code, notes, and snippets.

@alexwidua
alexwidua / ContentView.swift
Created July 4, 2023 17:07
SwiftUI Grid Animation
import SwiftUI
// 1. Use looped H/VStacks to create a grid
// 2. Conditionally increase spacing to grow/shrink the grid
// 3. Calculate the distance of each dot to the center and use the value to stagger the animation
//4. Add random delay on top of the staggered delay value
struct ContentView: View {
// const & state
@nilshoenson
nilshoenson / Shader.metal
Last active August 25, 2024 07:19
A wave animation built with shaders in SwiftUI.
#include <metal_stdlib>
#include <SwiftUI/SwiftUI_Metal.h>
using namespace metal;
// Create a horizontal bar
float bar(vector_float2 uv, float start, float height) {
return step(uv.y, height + start) - step(uv.y, start);
}
// Create waves animation using GLSL

概要

  • やりたいことは、コマンドをasyncで非同期に呼び出せるようすること。
    • バックグラウンドで処理を実行させ、キャンセルボタンで処理を中断できるようにする

image

問題点

  • 問題として、xcodebuildを行ったときに処理が完了しないが
  • 具体的にはprocess.isRunningfalseにならない
@Koshimizu-Takehito
Koshimizu-Takehito / RandomMetaballDemoScreen.swift
Last active April 27, 2025 02:50
A view that displays a glowing "metaball" particle effect with randomized circles.
import Combine
import SwiftUI
// MARK: - Demo View
/// A demo screen showcasing the `RandomMetaball2DView`.
///
/// This screen expands to fill the entire safe area.
struct RandomMetaballDemoScreen: View {
var body: some View {
struct AfterFiveIntroAnimation: View {
@State private var appearText = false
@State private var goLeft = false
@State private var goRight = false
@State private var showStartPageScreen = false
@Namespace var startPageAppear
var body: some View {
VStack {
@SwiftyAlex
SwiftyAlex / whatnotview.swift
Last active February 18, 2023 18:21
lil animation ❤️
import SwiftUI
struct WhatNotView<
OffCircleContent: View,
OnCircleContent: View,
OffTrailingContent: View,
OnTrailingContent: View
>: View {
@State var toggle: Bool = false
@ScaledMetric var scale: CGFloat = 1
//
// Blobs.swift
// SwiftUI Demos
//
// Created by Morten Just on 1/31/23.
//
import SwiftUI
struct Blobs: View {
//
// DarkModeMasker.swift
// SwiftUI Demos
//
// Created by Morten Just on 1/22/23.
// https://twitter.com/joshguospace/status/1617101052192649216?s=12
import SwiftUI
import Charts
@CharlyWargnier
CharlyWargnier / GTP3_script_for_sheets.txt
Created January 15, 2023 15:00
A script to integrate GTP3 in Google Sheets
const OPENAI_API_KEY = ""; // <- PASTE YOUR SECRET KEY HERE
const OPENAI_API_URL = "https://api.openai.com/v1/completions";
/**
* Submits a prompt to GPT-3 and returns the completion
*
* @param {string} prompt Prompt to submit to GPT-3
* @param {float} temperature Model temperature (0-1)
* @param {string} model Model name (e.g. text-davinci-002)
@minsOne
minsOne / Runtime.swift
Last active February 14, 2023 09:30 — forked from codelynx/Runtime.swift
[Swift] To retrieve classes at runtime which conforms to a protocol or to retrieve subclasses of a given class
//
// Runtime.swift
// Swift Runtime [Swift 4]
//
// The MIT License (MIT)
//
// Copyright (c) 2016 Electricwoods LLC, Kaz Yoshikawa.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal