This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TrimmingExample.swift | |
// | |
// Created by Vasilis Akoinoglou on 13/5/24. | |
// | |
import SwiftUI | |
struct Line: Identifiable { | |
let id = UUID() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// taken 2018-03-19 from wikipedia. https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 | |
enum Iso3166_1a2: String { | |
case af = "AF" | |
case ax = "AX" | |
case al = "AL" | |
case dz = "DZ" | |
case `as` = "AS" | |
case ad = "AD" | |
case ao = "AO" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Just for clarity of intention | |
typealias AbsolutePoint = CGPoint | |
typealias RelativePoint = CGPoint | |
func * (lhs: CGSize, rhs: CGSize) -> CGSize { | |
.init(width: lhs.width * rhs.width, height: lhs.height * rhs.height) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct TimingCurveView: View { | |
@State var value: CGFloat = 0 | |
@State var cp1: RelativePoint = .zero | |
@State var cp2: RelativePoint = .zero | |
let timer = Timer.publish(every: 2, on: .main, in: .common).autoconnect() | |
var animation: Animation { | |
Animation.timingCurve( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct CurveEditorView: View { | |
// 1 | |
private let initialPoint0: CGSize = .init(width: 0.4, height: 0.3) | |
private let initialPoint1: CGSize = .init(width: 0.6, height: 0.6) | |
// 2 | |
@State private var offsetPoint0: CGSize = .zero | |
@State private var offsetPoint1: CGSize = .zero |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct CurveShape: Shape { | |
let cp0, cp1: RelativePoint | |
func path(in rect: CGRect) -> Path { | |
Path { p in | |
p.move(to: CGPoint(x: 0, y: rect.size.height)) | |
p.addCurve(to: CGPoint(x: rect.size.width, y: 0), | |
control1: cp0 * rect.size, | |
control2: cp1 * rect.size) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Draggable: ViewModifier { | |
@State var isDragging: Bool = false | |
@State var offset: CGSize = .zero | |
@State var dragOffset: CGSize = .zero | |
var onChanged: ((CGSize) -> Void)? | |
var onEnded: ((CGSize) -> Void)? | |
func body(content: Content) -> some View { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ControlPointHandle: View { | |
private let size: CGFloat = 20 | |
var body: some View { | |
Circle() | |
.frame(width: size, height: size) | |
.overlay( | |
Circle() | |
.stroke(Color.white, lineWidth: 2) | |
) | |
.offset(x: -size/2, y: -size/2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
import SwiftUI | |
func startApp(content: NSView) { | |
let app = NSApplication.shared | |
let menubar = NSMenu() | |
let appMenuItem = NSMenuItem() | |
let appMenu = NSMenu() | |
let appName = ProcessInfo.processInfo.processName | |
let quitTitle = "Quit \(appName)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
var addresses = Set<String>() | |
class MyCell: UITableViewCell { | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) | |
} |
NewerOlder