Repository Public MIT
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// Project : SP GlassKit7// File : Sources/SPGlassTokens/GlassMotion.swift8// Module : SPGlassTokens9// Repository : https://git.spboucher.ai/sp-glasskit10// Project Website : https://glass.spboucher.ai11// Created : 2026-12-0212// Last Modified : 2026-12-0213//14// Author : Simon-Pierre Boucher15// Position : Professor of Finance16// Institution : Université du Québec en Outaouais (UQO)17// Organization : SP Boucher18// Website : https://spboucher.ai19// Git : https://git.spboucher.ai20//21// Preferred Contact: contact@spboucher.ai22// Development : dev@spboucher.ai23// Support : support@spboucher.ai24// Security/Admin : admin@spboucher.ai25//26// Copyright (c) 202627// Simon-Pierre Boucher28// All rights reserved where applicable. This file is governed by the29// applicable project license, copyright notices and relevant law.30// Existing third-party rights and notices remain unaffected.31//32// License : MIT33//34// Do not embed credentials, private keys, access tokens,35// certificates or confidential personal information.36//37// =============================================================================38// END OF SP BOUCHER SOURCE HEADER39// =============================================================================4041import Foundation4243public enum GlassMotionStyle: String, Codable, CaseIterable, Sendable {44 case smooth, snappy, bouncy45}4647public enum GlassMotionSpeed: String, Codable, CaseIterable, Sendable {48 case fast, standard, slow49}5051/// Animation tokens. Durations are in seconds and bounded to 0...2 by validation.52public struct GlassMotion: Hashable, Codable, Sendable {53 public var style: GlassMotionStyle54 public var fast: Double55 public var standard: Double56 public var slow: Double5758 public init(style: GlassMotionStyle = .smooth, fast: Double = 0.15, standard: Double = 0.25, slow: Double = 0.4) {59 self.style = style; self.fast = fast; self.standard = standard; self.slow = slow60 }6162 public init(from decoder: any Decoder) throws {63 let c = try decoder.container(keyedBy: CodingKeys.self)64 let d = GlassMotion()65 style = try c.decodeIfPresent(GlassMotionStyle.self, forKey: .style) ?? d.style66 fast = try c.decodeIfPresent(Double.self, forKey: .fast) ?? d.fast67 standard = try c.decodeIfPresent(Double.self, forKey: .standard) ?? d.standard68 slow = try c.decodeIfPresent(Double.self, forKey: .slow) ?? d.slow69 }7071 public func duration(_ speed: GlassMotionSpeed) -> Double {72 switch speed {73 case .fast: fast74 case .standard: standard75 case .slow: slow76 }77 }7879 public static let standardMotion = GlassMotion()80}81