├── LICENSE ├── README.md ├── SwiftMathDemo.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── swiftpm │ │ │ └── Package.resolved │ └── xcuserdata │ │ └── mikeg.xcuserdatad │ │ └── IDEFindNavigatorScopes.plist └── xcuserdata │ └── mikeg.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── SwiftMathDemo ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── ContentView.swift ├── MathView.swift ├── Preview Content │ └── Preview Assets.xcassets │ │ └── Contents.json ├── README.md ├── SwiftMathDemo.entitlements ├── SwiftMathDemoApp.swift └── images │ ├── iMac.png │ ├── iPad.png │ └── iPhone.png └── images ├── darkiMac.png ├── darkiPad.png ├── darkiPhone.png ├── lighiPhone.png ├── lightiMac.png └── lightiPad.png /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Computer Inspirations 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftMathDemo 2 | 3 | `SwiftMathDemo` demonstrates the use of [SwiftMath](https://github.com/mgriebling/SwiftMath.git) using SwiftUI. 4 | The same code runs on Macs, iPhones, and iPads. Code is entirely written in Swift. 5 | The `MathView.swift` file provides a `SwiftMath` interface to SwiftUI. 6 | Simplified setting fonts in the MathView and the demo. 7 | 8 | To use `SwiftMath` in your own code, just add the following package path to 9 | XCode: https://github.com/mgriebling/SwiftMath.git 10 | 11 | ## Examples 12 | Here are screenshots of an iPad, iPhone, and Mac running the demo: 13 | 14 | ![iPad Screenshot](images/lightiPad.png#gh-light-mode-only) 15 | ![iPad Screenshot](images/darkiPad.png#gh-dark-mode-only) 16 | 17 | ![iPhone Screenshot](images/darkiPhone.png#gh-dark-mode-only) 18 | ![iPhone Screenshot](images/lightiPhone.png#gh-light-mode-only) 19 | 20 | ![Quadratic Formula](images/darkiMac.png#gh-dark-mode-only) 21 | ![Quadratic Formula](images/lightiMac.png#gh-light-mode-only) 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftMathDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 4705289E2CB17CFD00018B50 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 4705289D2CB17CFD00018B50 /* SwiftMath */; }; 11 | 470528A72CB1934800018B50 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 470528A62CB1934800018B50 /* SwiftMath */; }; 12 | 470528AA2CB1938300018B50 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 470528A92CB1938300018B50 /* SwiftMath */; }; 13 | 470528AD2CB193F400018B50 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 470528AC2CB193F400018B50 /* SwiftMath */; }; 14 | 470528B02CB1944000018B50 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 470528AF2CB1944000018B50 /* SwiftMath */; }; 15 | 470528B62CB1A89A00018B50 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 470528B52CB1A89A00018B50 /* SwiftMath */; }; 16 | 470528C52CB33AA300018B50 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 470528C42CB33AA300018B50 /* SwiftMath */; }; 17 | 475A6BEB2CB5B87A0087735E /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 475A6BEA2CB5B87A0087735E /* SwiftMath */; }; 18 | 475B5F712D1314B9008D4C95 /* darkiMac.png in Resources */ = {isa = PBXBuildFile; fileRef = 475B5F702D1314B9008D4C95 /* darkiMac.png */; }; 19 | 475B5F732D1314DB008D4C95 /* lightiMac.png in Resources */ = {isa = PBXBuildFile; fileRef = 475B5F722D1314DB008D4C95 /* lightiMac.png */; }; 20 | 475B5F752D131649008D4C95 /* lightiPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 475B5F742D131649008D4C95 /* lightiPad.png */; }; 21 | 475B5F772D131658008D4C95 /* darkiPad.png in Resources */ = {isa = PBXBuildFile; fileRef = 475B5F762D131658008D4C95 /* darkiPad.png */; }; 22 | 475B5F7A2D131B04008D4C95 /* darkiPhone.png in Resources */ = {isa = PBXBuildFile; fileRef = 475B5F782D131B04008D4C95 /* darkiPhone.png */; }; 23 | 475B5F7B2D131B04008D4C95 /* lighiPhone.png in Resources */ = {isa = PBXBuildFile; fileRef = 475B5F792D131B04008D4C95 /* lighiPhone.png */; }; 24 | 476F8FA62D132C7E00BA4982 /* SwiftMath in Frameworks */ = {isa = PBXBuildFile; productRef = 476F8FA52D132C7E00BA4982 /* SwiftMath */; }; 25 | 479B9A132979F0730029C406 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 479B9A122979F0730029C406 /* README.md */; }; 26 | 47D14F27297898C00072F28E /* SwiftMathDemoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47D14F26297898C00072F28E /* SwiftMathDemoApp.swift */; }; 27 | 47D14F29297898C00072F28E /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47D14F28297898C00072F28E /* ContentView.swift */; }; 28 | 47D14F2B297898C10072F28E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 47D14F2A297898C10072F28E /* Assets.xcassets */; }; 29 | 47D14F2F297898C10072F28E /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 47D14F2E297898C10072F28E /* Preview Assets.xcassets */; }; 30 | 47D14F362978994D0072F28E /* MathView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47D14F352978994D0072F28E /* MathView.swift */; }; 31 | /* End PBXBuildFile section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 475B5F702D1314B9008D4C95 /* darkiMac.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = darkiMac.png; sourceTree = ""; }; 35 | 475B5F722D1314DB008D4C95 /* lightiMac.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lightiMac.png; sourceTree = ""; }; 36 | 475B5F742D131649008D4C95 /* lightiPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lightiPad.png; sourceTree = ""; }; 37 | 475B5F762D131658008D4C95 /* darkiPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = darkiPad.png; sourceTree = ""; }; 38 | 475B5F782D131B04008D4C95 /* darkiPhone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = darkiPhone.png; sourceTree = ""; }; 39 | 475B5F792D131B04008D4C95 /* lighiPhone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = lighiPhone.png; sourceTree = ""; }; 40 | 479B9A122979F0730029C406 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 41 | 47D14F23297898C00072F28E /* SwiftMathDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftMathDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | 47D14F26297898C00072F28E /* SwiftMathDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftMathDemoApp.swift; sourceTree = ""; }; 43 | 47D14F28297898C00072F28E /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 44 | 47D14F2A297898C10072F28E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 45 | 47D14F2C297898C10072F28E /* SwiftMathDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SwiftMathDemo.entitlements; sourceTree = ""; }; 46 | 47D14F2E297898C10072F28E /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 47 | 47D14F352978994D0072F28E /* MathView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MathView.swift; sourceTree = ""; }; 48 | /* End PBXFileReference section */ 49 | 50 | /* Begin PBXFrameworksBuildPhase section */ 51 | 47D14F20297898C00072F28E /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | 475A6BEB2CB5B87A0087735E /* SwiftMath in Frameworks */, 56 | 470528AD2CB193F400018B50 /* SwiftMath in Frameworks */, 57 | 470528A72CB1934800018B50 /* SwiftMath in Frameworks */, 58 | 470528B62CB1A89A00018B50 /* SwiftMath in Frameworks */, 59 | 470528B02CB1944000018B50 /* SwiftMath in Frameworks */, 60 | 4705289E2CB17CFD00018B50 /* SwiftMath in Frameworks */, 61 | 470528AA2CB1938300018B50 /* SwiftMath in Frameworks */, 62 | 470528C52CB33AA300018B50 /* SwiftMath in Frameworks */, 63 | 476F8FA62D132C7E00BA4982 /* SwiftMath in Frameworks */, 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | /* End PBXFrameworksBuildPhase section */ 68 | 69 | /* Begin PBXGroup section */ 70 | 479B9A162979F09D0029C406 /* images */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 475B5F702D1314B9008D4C95 /* darkiMac.png */, 74 | 475B5F782D131B04008D4C95 /* darkiPhone.png */, 75 | 475B5F792D131B04008D4C95 /* lighiPhone.png */, 76 | 475B5F722D1314DB008D4C95 /* lightiMac.png */, 77 | 475B5F762D131658008D4C95 /* darkiPad.png */, 78 | 475B5F742D131649008D4C95 /* lightiPad.png */, 79 | ); 80 | name = images; 81 | path = ../images; 82 | sourceTree = ""; 83 | }; 84 | 47D14F1A297898C00072F28E = { 85 | isa = PBXGroup; 86 | children = ( 87 | 47D14F25297898C00072F28E /* SwiftMathDemo */, 88 | 47D14F24297898C00072F28E /* Products */, 89 | ); 90 | sourceTree = ""; 91 | }; 92 | 47D14F24297898C00072F28E /* Products */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 47D14F23297898C00072F28E /* SwiftMathDemo.app */, 96 | ); 97 | name = Products; 98 | sourceTree = ""; 99 | }; 100 | 47D14F25297898C00072F28E /* SwiftMathDemo */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | 479B9A122979F0730029C406 /* README.md */, 104 | 479B9A162979F09D0029C406 /* images */, 105 | 47D14F26297898C00072F28E /* SwiftMathDemoApp.swift */, 106 | 47D14F28297898C00072F28E /* ContentView.swift */, 107 | 47D14F352978994D0072F28E /* MathView.swift */, 108 | 47D14F2A297898C10072F28E /* Assets.xcassets */, 109 | 47D14F2C297898C10072F28E /* SwiftMathDemo.entitlements */, 110 | 47D14F2D297898C10072F28E /* Preview Content */, 111 | ); 112 | path = SwiftMathDemo; 113 | sourceTree = ""; 114 | }; 115 | 47D14F2D297898C10072F28E /* Preview Content */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 47D14F2E297898C10072F28E /* Preview Assets.xcassets */, 119 | ); 120 | path = "Preview Content"; 121 | sourceTree = ""; 122 | }; 123 | /* End PBXGroup section */ 124 | 125 | /* Begin PBXNativeTarget section */ 126 | 47D14F22297898C00072F28E /* SwiftMathDemo */ = { 127 | isa = PBXNativeTarget; 128 | buildConfigurationList = 47D14F32297898C10072F28E /* Build configuration list for PBXNativeTarget "SwiftMathDemo" */; 129 | buildPhases = ( 130 | 47D14F1F297898C00072F28E /* Sources */, 131 | 47D14F20297898C00072F28E /* Frameworks */, 132 | 47D14F21297898C00072F28E /* Resources */, 133 | ); 134 | buildRules = ( 135 | ); 136 | dependencies = ( 137 | ); 138 | name = SwiftMathDemo; 139 | packageProductDependencies = ( 140 | 4705289D2CB17CFD00018B50 /* SwiftMath */, 141 | 470528A62CB1934800018B50 /* SwiftMath */, 142 | 470528A92CB1938300018B50 /* SwiftMath */, 143 | 470528AC2CB193F400018B50 /* SwiftMath */, 144 | 470528AF2CB1944000018B50 /* SwiftMath */, 145 | 470528B52CB1A89A00018B50 /* SwiftMath */, 146 | 470528C42CB33AA300018B50 /* SwiftMath */, 147 | 475A6BEA2CB5B87A0087735E /* SwiftMath */, 148 | 476F8FA52D132C7E00BA4982 /* SwiftMath */, 149 | ); 150 | productName = SwiftMathDemo; 151 | productReference = 47D14F23297898C00072F28E /* SwiftMathDemo.app */; 152 | productType = "com.apple.product-type.application"; 153 | }; 154 | /* End PBXNativeTarget section */ 155 | 156 | /* Begin PBXProject section */ 157 | 47D14F1B297898C00072F28E /* Project object */ = { 158 | isa = PBXProject; 159 | attributes = { 160 | BuildIndependentTargetsInParallel = 1; 161 | LastSwiftUpdateCheck = 1420; 162 | LastUpgradeCheck = 1620; 163 | TargetAttributes = { 164 | 47D14F22297898C00072F28E = { 165 | CreatedOnToolsVersion = 14.2; 166 | }; 167 | }; 168 | }; 169 | buildConfigurationList = 47D14F1E297898C00072F28E /* Build configuration list for PBXProject "SwiftMathDemo" */; 170 | compatibilityVersion = "Xcode 14.0"; 171 | developmentRegion = en; 172 | hasScannedForEncodings = 0; 173 | knownRegions = ( 174 | en, 175 | Base, 176 | ); 177 | mainGroup = 47D14F1A297898C00072F28E; 178 | packageReferences = ( 179 | 476F8FA42D132C7E00BA4982 /* XCRemoteSwiftPackageReference "SwiftMath" */, 180 | ); 181 | productRefGroup = 47D14F24297898C00072F28E /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | 47D14F22297898C00072F28E /* SwiftMathDemo */, 186 | ); 187 | }; 188 | /* End PBXProject section */ 189 | 190 | /* Begin PBXResourcesBuildPhase section */ 191 | 47D14F21297898C00072F28E /* Resources */ = { 192 | isa = PBXResourcesBuildPhase; 193 | buildActionMask = 2147483647; 194 | files = ( 195 | 479B9A132979F0730029C406 /* README.md in Resources */, 196 | 475B5F732D1314DB008D4C95 /* lightiMac.png in Resources */, 197 | 47D14F2F297898C10072F28E /* Preview Assets.xcassets in Resources */, 198 | 475B5F712D1314B9008D4C95 /* darkiMac.png in Resources */, 199 | 475B5F752D131649008D4C95 /* lightiPad.png in Resources */, 200 | 47D14F2B297898C10072F28E /* Assets.xcassets in Resources */, 201 | 475B5F7A2D131B04008D4C95 /* darkiPhone.png in Resources */, 202 | 475B5F7B2D131B04008D4C95 /* lighiPhone.png in Resources */, 203 | 475B5F772D131658008D4C95 /* darkiPad.png in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | 47D14F1F297898C00072F28E /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | 47D14F29297898C00072F28E /* ContentView.swift in Sources */, 215 | 47D14F362978994D0072F28E /* MathView.swift in Sources */, 216 | 47D14F27297898C00072F28E /* SwiftMathDemoApp.swift in Sources */, 217 | ); 218 | runOnlyForDeploymentPostprocessing = 0; 219 | }; 220 | /* End PBXSourcesBuildPhase section */ 221 | 222 | /* Begin XCBuildConfiguration section */ 223 | 47D14F30297898C10072F28E /* Debug */ = { 224 | isa = XCBuildConfiguration; 225 | buildSettings = { 226 | ALWAYS_SEARCH_USER_PATHS = NO; 227 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 228 | CLANG_ANALYZER_NONNULL = YES; 229 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 230 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 231 | CLANG_ENABLE_MODULES = YES; 232 | CLANG_ENABLE_OBJC_ARC = YES; 233 | CLANG_ENABLE_OBJC_WEAK = YES; 234 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 235 | CLANG_WARN_BOOL_CONVERSION = YES; 236 | CLANG_WARN_COMMA = YES; 237 | CLANG_WARN_CONSTANT_CONVERSION = YES; 238 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 239 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 240 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 241 | CLANG_WARN_EMPTY_BODY = YES; 242 | CLANG_WARN_ENUM_CONVERSION = YES; 243 | CLANG_WARN_INFINITE_RECURSION = YES; 244 | CLANG_WARN_INT_CONVERSION = YES; 245 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 246 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 247 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 248 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 249 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 250 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 251 | CLANG_WARN_STRICT_PROTOTYPES = YES; 252 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 253 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 254 | CLANG_WARN_UNREACHABLE_CODE = YES; 255 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 256 | COPY_PHASE_STRIP = NO; 257 | DEAD_CODE_STRIPPING = YES; 258 | DEBUG_INFORMATION_FORMAT = dwarf; 259 | ENABLE_STRICT_OBJC_MSGSEND = YES; 260 | ENABLE_TESTABILITY = YES; 261 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 262 | GCC_C_LANGUAGE_STANDARD = gnu11; 263 | GCC_DYNAMIC_NO_PIC = NO; 264 | GCC_NO_COMMON_BLOCKS = YES; 265 | GCC_OPTIMIZATION_LEVEL = 0; 266 | GCC_PREPROCESSOR_DEFINITIONS = ( 267 | "DEBUG=1", 268 | "$(inherited)", 269 | ); 270 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 271 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 272 | GCC_WARN_UNDECLARED_SELECTOR = YES; 273 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 274 | GCC_WARN_UNUSED_FUNCTION = YES; 275 | GCC_WARN_UNUSED_VARIABLE = YES; 276 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 277 | MTL_FAST_MATH = YES; 278 | ONLY_ACTIVE_ARCH = YES; 279 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 280 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 281 | }; 282 | name = Debug; 283 | }; 284 | 47D14F31297898C10072F28E /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ALWAYS_SEARCH_USER_PATHS = NO; 288 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 289 | CLANG_ANALYZER_NONNULL = YES; 290 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 291 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 292 | CLANG_ENABLE_MODULES = YES; 293 | CLANG_ENABLE_OBJC_ARC = YES; 294 | CLANG_ENABLE_OBJC_WEAK = YES; 295 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 296 | CLANG_WARN_BOOL_CONVERSION = YES; 297 | CLANG_WARN_COMMA = YES; 298 | CLANG_WARN_CONSTANT_CONVERSION = YES; 299 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 300 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 301 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 302 | CLANG_WARN_EMPTY_BODY = YES; 303 | CLANG_WARN_ENUM_CONVERSION = YES; 304 | CLANG_WARN_INFINITE_RECURSION = YES; 305 | CLANG_WARN_INT_CONVERSION = YES; 306 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 307 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 308 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 309 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 310 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 311 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 312 | CLANG_WARN_STRICT_PROTOTYPES = YES; 313 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 314 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 315 | CLANG_WARN_UNREACHABLE_CODE = YES; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | COPY_PHASE_STRIP = NO; 318 | DEAD_CODE_STRIPPING = YES; 319 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 320 | ENABLE_NS_ASSERTIONS = NO; 321 | ENABLE_STRICT_OBJC_MSGSEND = YES; 322 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 323 | GCC_C_LANGUAGE_STANDARD = gnu11; 324 | GCC_NO_COMMON_BLOCKS = YES; 325 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 326 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 327 | GCC_WARN_UNDECLARED_SELECTOR = YES; 328 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 329 | GCC_WARN_UNUSED_FUNCTION = YES; 330 | GCC_WARN_UNUSED_VARIABLE = YES; 331 | MTL_ENABLE_DEBUG_INFO = NO; 332 | MTL_FAST_MATH = YES; 333 | SWIFT_COMPILATION_MODE = wholemodule; 334 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 335 | }; 336 | name = Release; 337 | }; 338 | 47D14F33297898C10072F28E /* Debug */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 342 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 343 | CODE_SIGN_ENTITLEMENTS = SwiftMathDemo/SwiftMathDemo.entitlements; 344 | CODE_SIGN_IDENTITY = "Apple Development"; 345 | "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; 346 | CODE_SIGN_STYLE = Automatic; 347 | CURRENT_PROJECT_VERSION = 1; 348 | DEAD_CODE_STRIPPING = YES; 349 | DEVELOPMENT_ASSET_PATHS = "\"SwiftMathDemo/Preview Content\""; 350 | DEVELOPMENT_TEAM = 6389FT2N69; 351 | ENABLE_HARDENED_RUNTIME = YES; 352 | ENABLE_PREVIEWS = YES; 353 | GENERATE_INFOPLIST_FILE = YES; 354 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; 355 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; 356 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; 357 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; 358 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; 359 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; 360 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; 361 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; 362 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 363 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 364 | IPHONEOS_DEPLOYMENT_TARGET = 15.6; 365 | LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; 366 | "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; 367 | MACOSX_DEPLOYMENT_TARGET = 12.4; 368 | MARKETING_VERSION = 1.0; 369 | PRODUCT_BUNDLE_IDENTIFIER = "com.c-inspirations.SwiftMathDemo"; 370 | PRODUCT_NAME = "$(TARGET_NAME)"; 371 | PROVISIONING_PROFILE_SPECIFIER = ""; 372 | SDKROOT = auto; 373 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 374 | SWIFT_EMIT_LOC_STRINGS = YES; 375 | SWIFT_VERSION = 5.0; 376 | TARGETED_DEVICE_FAMILY = "1,2"; 377 | }; 378 | name = Debug; 379 | }; 380 | 47D14F34297898C10072F28E /* Release */ = { 381 | isa = XCBuildConfiguration; 382 | buildSettings = { 383 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 384 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 385 | CODE_SIGN_ENTITLEMENTS = SwiftMathDemo/SwiftMathDemo.entitlements; 386 | CODE_SIGN_IDENTITY = "Apple Development"; 387 | "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; 388 | CODE_SIGN_STYLE = Automatic; 389 | CURRENT_PROJECT_VERSION = 1; 390 | DEAD_CODE_STRIPPING = YES; 391 | DEVELOPMENT_ASSET_PATHS = "\"SwiftMathDemo/Preview Content\""; 392 | DEVELOPMENT_TEAM = 6389FT2N69; 393 | ENABLE_HARDENED_RUNTIME = YES; 394 | ENABLE_PREVIEWS = YES; 395 | GENERATE_INFOPLIST_FILE = YES; 396 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES; 397 | "INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES; 398 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES; 399 | "INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES; 400 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES; 401 | "INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES; 402 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault; 403 | "INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault; 404 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 405 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 406 | IPHONEOS_DEPLOYMENT_TARGET = 15.6; 407 | LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; 408 | "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; 409 | MACOSX_DEPLOYMENT_TARGET = 12.4; 410 | MARKETING_VERSION = 1.0; 411 | PRODUCT_BUNDLE_IDENTIFIER = "com.c-inspirations.SwiftMathDemo"; 412 | PRODUCT_NAME = "$(TARGET_NAME)"; 413 | PROVISIONING_PROFILE_SPECIFIER = ""; 414 | SDKROOT = auto; 415 | SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx"; 416 | SWIFT_EMIT_LOC_STRINGS = YES; 417 | SWIFT_VERSION = 5.0; 418 | TARGETED_DEVICE_FAMILY = "1,2"; 419 | }; 420 | name = Release; 421 | }; 422 | /* End XCBuildConfiguration section */ 423 | 424 | /* Begin XCConfigurationList section */ 425 | 47D14F1E297898C00072F28E /* Build configuration list for PBXProject "SwiftMathDemo" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | 47D14F30297898C10072F28E /* Debug */, 429 | 47D14F31297898C10072F28E /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | 47D14F32297898C10072F28E /* Build configuration list for PBXNativeTarget "SwiftMathDemo" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 47D14F33297898C10072F28E /* Debug */, 438 | 47D14F34297898C10072F28E /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | /* End XCConfigurationList section */ 444 | 445 | /* Begin XCRemoteSwiftPackageReference section */ 446 | 476F8FA42D132C7E00BA4982 /* XCRemoteSwiftPackageReference "SwiftMath" */ = { 447 | isa = XCRemoteSwiftPackageReference; 448 | repositoryURL = "https://github.com/mgriebling/SwiftMath"; 449 | requirement = { 450 | kind = upToNextMajorVersion; 451 | minimumVersion = 1.7.0; 452 | }; 453 | }; 454 | /* End XCRemoteSwiftPackageReference section */ 455 | 456 | /* Begin XCSwiftPackageProductDependency section */ 457 | 4705289D2CB17CFD00018B50 /* SwiftMath */ = { 458 | isa = XCSwiftPackageProductDependency; 459 | productName = SwiftMath; 460 | }; 461 | 470528A62CB1934800018B50 /* SwiftMath */ = { 462 | isa = XCSwiftPackageProductDependency; 463 | productName = SwiftMath; 464 | }; 465 | 470528A92CB1938300018B50 /* SwiftMath */ = { 466 | isa = XCSwiftPackageProductDependency; 467 | productName = SwiftMath; 468 | }; 469 | 470528AC2CB193F400018B50 /* SwiftMath */ = { 470 | isa = XCSwiftPackageProductDependency; 471 | productName = SwiftMath; 472 | }; 473 | 470528AF2CB1944000018B50 /* SwiftMath */ = { 474 | isa = XCSwiftPackageProductDependency; 475 | productName = SwiftMath; 476 | }; 477 | 470528B52CB1A89A00018B50 /* SwiftMath */ = { 478 | isa = XCSwiftPackageProductDependency; 479 | productName = SwiftMath; 480 | }; 481 | 470528C42CB33AA300018B50 /* SwiftMath */ = { 482 | isa = XCSwiftPackageProductDependency; 483 | productName = SwiftMath; 484 | }; 485 | 475A6BEA2CB5B87A0087735E /* SwiftMath */ = { 486 | isa = XCSwiftPackageProductDependency; 487 | productName = SwiftMath; 488 | }; 489 | 476F8FA52D132C7E00BA4982 /* SwiftMath */ = { 490 | isa = XCSwiftPackageProductDependency; 491 | package = 476F8FA42D132C7E00BA4982 /* XCRemoteSwiftPackageReference "SwiftMath" */; 492 | productName = SwiftMath; 493 | }; 494 | /* End XCSwiftPackageProductDependency section */ 495 | }; 496 | rootObject = 47D14F1B297898C00072F28E /* Project object */; 497 | } 498 | -------------------------------------------------------------------------------- /SwiftMathDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftMathDemo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "originHash" : "29f526ddf21aff91e22b71258249b75b0a71df40a56c1f318f84c93fe3a90425", 3 | "pins" : [ 4 | { 5 | "identity" : "swiftmath", 6 | "kind" : "remoteSourceControl", 7 | "location" : "https://github.com/mgriebling/SwiftMath.git", 8 | "state" : { 9 | "revision" : "5c251ad21812f4d129dd8a2886723e5eabfc6054", 10 | "version" : "1.7.0" 11 | } 12 | } 13 | ], 14 | "version" : 3 15 | } 16 | -------------------------------------------------------------------------------- /SwiftMathDemo.xcodeproj/project.xcworkspace/xcuserdata/mikeg.xcuserdatad/IDEFindNavigatorScopes.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SwiftMathDemo.xcodeproj/xcuserdata/mikeg.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /SwiftMathDemo.xcodeproj/xcuserdata/mikeg.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SwiftMathDemo.xcscheme_^#shared#^_ 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SwiftMathDemo/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SwiftMathDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "scale" : "1x", 11 | "size" : "16x16" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "scale" : "2x", 16 | "size" : "16x16" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "scale" : "1x", 21 | "size" : "32x32" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "scale" : "2x", 26 | "size" : "32x32" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "scale" : "1x", 31 | "size" : "128x128" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "scale" : "2x", 36 | "size" : "128x128" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "scale" : "1x", 41 | "size" : "256x256" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "scale" : "2x", 46 | "size" : "256x256" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "scale" : "1x", 51 | "size" : "512x512" 52 | }, 53 | { 54 | "idiom" : "mac", 55 | "scale" : "2x", 56 | "size" : "512x512" 57 | } 58 | ], 59 | "info" : { 60 | "author" : "xcode", 61 | "version" : 1 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SwiftMathDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftMathDemo/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // SwiftMathDemo 4 | // 5 | // Created by Mike Griebling on 2023-01-18. 6 | // 7 | 8 | import SwiftUI 9 | import SwiftMath 10 | 11 | struct ContentView: View { 12 | 13 | /// Set to *true* to preview the fonts 14 | let previewFonts = false 15 | 16 | let demoLabels = [ 17 | "x_i\\in[-1{,}5;1,5]", 18 | "\\text{Accented characters: áéíóúýàèìòùâêîôûäëïöüÿãñõ}", 19 | "\\text{Special: çøåæœß'ÇØÅÆŒ}", 20 | "\\text{Uppercase: ÁÉÍÓÚÝÀÈÌÒÙÂÊÎÔÛÄËÏÖÜÃÑÕ}", 21 | "\\text{Accents: \\hat{o}, \\check{o}, \\tilde{o}, \\acute{i}, \\grave{o}, \\ddot{o}, \\dot{o}, \\breve{o}, `, \", \\upquote}, \\aa", 22 | "\\text{Quadratic roots: }x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}", 23 | "\\color{#ff3399}{(a_1+a_2)^2}=a_1^2+2a_1a_2+a_2^2", 24 | "\\cos(\\theta + \\varphi) = \\cos(\\theta)\\cos(\\varphi) - \\sin(\\theta)\\sin(\\varphi)", 25 | """ 26 | \\frac{1}{\\left(\\sqrt{\\phi \\sqrt{5}}-\\phi\\right) e^{\\frac25 \\pi}} 27 | = 1+\\frac{e^{-2\\piā} {1 +\\frac{e^{-4\\pi}} {1+\\frac{e^{-6\\pi}} {1+\\frac{e^{-8\\pi}} {1+\\cdots} } } } 28 | """, 29 | "\\sigma = \\sqrt{\\frac{1}{N}\\sum_{i=1}^N (x_i - \\mu)^2}", 30 | "\\neg(P\\land Q) \\iff (\\neg P)\\lor(\\neg Q)", 31 | "\\log_b(x) = \\frac{\\log_a(x)}{\\log_a(b)}", 32 | "\\lim_{x\\to\\infty}\\left(1 + \\frac{k}{x}\\right)^x = e^k", 33 | "\\int_{-\\infty}^\\infty \\! e^{-x^2} dx = \\sqrt{\\pi}", 34 | "\\frac 1 n \\sum_{i=1}^{n}x_i \\geq \\sqrt[n]{\\prod_{i=1}^{n}x_i}", 35 | "f^{(n)}(z_0) = \\frac{n!}{2\\pi i}\\oint_\\gamma\\frac{f(z)}{(z-z_0)^{n+1}}\\,dz", 36 | "i\\hbar\\frac{\\partial}{\\partial t}\\mathbf\\Psi(\\mathbf{x},t) = " + 37 | "-\\frac{\\hbar}{2m}\\nabla^2\\mathbf\\Psi(\\mathbf{x},t) + V(\\mathbf{x})\\mathbf\\Psi(\\mathbf{x},t)", 38 | "\\left(\\sum_{k=1}^n a_k b_k \\right)^2 \\le \\left(\\sum_{k=1}^n a_k^2\\right)\\left(\\sum_{k=1}^n b_k^2\\right)", 39 | "{n \\brace k} = \\frac{1}{k!}\\sum_{j=0}^k (-1)^{k-j}\\binom{k}{j}(k-j)^n", 40 | "f(x) = \\int\\limits_{-\\infty}^\\infty\\!\\hat f(\\xi)\\,e^{2 \\pi i \\xi x}\\,\\mathrm{d}\\xi", 41 | """ 42 | \\begin{gather} 43 | \\dot{x} = \\sigma(y-x) \\\\ 44 | \\dot{y} = \\rho x - y - xz \\\\ 45 | \\dot{z} = -\\beta z + xy 46 | \\end{gather} 47 | """, 48 | """ 49 | \\vec \\bf V_1 \\times \\vec \\bf V_2 = 50 | \\begin{vmatrix} 51 | \\hat \\imath &\\hat \\jmath &\\hat k \\\\ 52 | \\frac{\\partial X}{\\partial u} & \\frac{\\partial Y}{\\partial u} & 0 \\\\ 53 | \\frac{\\partial X}{\\partial v} & \\frac{\\partial Y}{\\partial v} & 0 54 | \\end{vmatrix} 55 | """, 56 | """ 57 | \\begin{eqalign} 58 | \\nabla \\cdot \\vec{\\bf{E}} & = \\frac {\\rho} {\\varepsilon_0} \\\\ 59 | \\nabla \\cdot \\vec{\\bf{B}} & = 0 \\\\ 60 | \\nabla \\times \\vec{\\bf{E}} &= - 61 | \\frac{\\partial\\vec{\\bf{B}}}{\\partial t} \\\\ 62 | \\nabla \\times \\vec{\\bf{B}} & = \\mu_0\\vec{\\bf{J}} + 63 | \\mu_0\\varepsilon_0 \\frac{\\partial\\vec{\\bf{E}}}{\\partial t} 64 | \\end{eqalign} 65 | """, 66 | """ 67 | \\begin{pmatrix} 68 | a & b\\\\ c & d 69 | \\end{pmatrix} 70 | \\begin{pmatrix} 71 | \\alpha & \\beta \\\\ \\gamma & \\delta 72 | \\end{pmatrix} = 73 | \\begin{pmatrix} 74 | a\\alpha + b\\gamma & a\\beta + b \\delta \\\\ 75 | c\\alpha + d\\gamma & c\\beta + d \\delta 76 | \\end{pmatrix} 77 | """, 78 | """ 79 | \\frak Q(\\lambda,\\hat{\\lambda}) = 80 | -\\frac{1}{2} \\mathbb P(O \\mid \\lambda ) \\sum_s \\sum_m \\sum_t \\gamma_m^{(s)} (t) + \\\\ 81 | \\quad \\left( \\log(2 \\pi ) + \\log \\left| \\cal C_m^{(s)} \\right| + 82 | \\left( o_t - \\hat{\\mu}_m^{(s)} \\right) ^T \\cal C_m^{(s)-1} \\right) 83 | """, 84 | """ 85 | f(x) = \\begin{cases} 86 | \\frac{e^x}{2} & x \\geq 0 \\\\ 87 | 1 & x < 0 88 | \\end{cases} 89 | """, 90 | """ 91 | \\color{#ff3333}{c}\\color{#9933ff}{o}\\color{#ff0080}{l}+ 92 | \\color{#99ff33}{\\frac{\\color{#ff99ff}{o}} {\\color{#990099}{r}}}-\\color{#33ffff}{\\sqrt[\\color{#3399ff}{e}]{\\color{#3333ff}{d}}} 93 | """ 94 | ] 95 | let r20 = MTEdgeInsets(top: 0, left: 0, bottom: 0, right: 20) 96 | let z = MTEdgeInsets() 97 | let back = Color(hue: 0.15, saturation: 0.2, brightness: 0.5) 98 | let display = MTMathUILabelMode.display 99 | let text = MTMathUILabelMode.text 100 | let left = MTTextAlignment.left 101 | let right = MTTextAlignment.right 102 | let center = MTTextAlignment.center 103 | let bb = Color.clear 104 | 105 | struct DemoText : Identifiable { 106 | let s: String 107 | let c: Color 108 | let a: MTTextAlignment 109 | let i: MTEdgeInsets 110 | let m: MTMathUILabelMode 111 | let w: CGFloat 112 | let id = UUID() 113 | 114 | init(_ s: String, _ c: Color = .clear, _ a: MTTextAlignment = .left, 115 | _ i: MTEdgeInsets = MTEdgeInsets(), 116 | _ m: MTMathUILabelMode = .display, _ w: CGFloat = 30) { 117 | self.s = s 118 | self.c = c 119 | self.a = a 120 | self.i = i 121 | self.m = m 122 | self.w = w 123 | } 124 | } 125 | 126 | func fancy() -> [DemoText] { 127 | [ 128 | DemoText("3+2-5 = 0", back), 129 | DemoText("12+-3 > +14", back, center), 130 | DemoText("(-3-5=-8, -6-7=-13)"), 131 | DemoText("5\\times(-2 \\div 1) = -10", back, right, r20), 132 | DemoText("-h - (5xy+2) = z"), 133 | DemoText("\\frac12x + \\frac{3\\div4}2y = 25", bb, left, z, text), 134 | DemoText("\\frac{x+\\frac{12}{5}}{y}+\\frac1z = \\frac{xz+y+\\frac{12}{5}z}{yz}", back), 135 | DemoText("\\frac{x+\\frac{12}{5}}{y}+\\frac1z = \\frac{xz+y+\\frac{12}{5}z}{yz} ", back, left, z, text), 136 | DemoText("\\frac{x^{2+3y}}{x^{2+4y}} = x^y \\times \\frac{z_1^{y+1}}{z_1^{y+1}}", bb, left, z, display, 40), 137 | DemoText("\\frac{x^{2+3y}}{x^{2+4y}} = x^y \\times \\frac{z_1^{y+1}}{z_1^{y+1}} "), 138 | DemoText("5+\\sqrt{2}+3"), 139 | DemoText("\\sqrt{\\frac{\\sqrt{\\frac{1}{2}} + 3}{\\sqrt5^x}}+\\sqrt{3x}+x^{\\sqrt2}"), 140 | DemoText("\\sqrt[3]{24} + 3\\sqrt{2}24"), 141 | DemoText("\\sqrt[x+\\frac{3}{4}]{\\frac{2}{4}+1}"), 142 | DemoText("\\sin^2(\\theta)=\\log_3^2(\\pi)"), 143 | DemoText("\\lim_{x\\to\\infty}\\frac{e^2}{1-x}=\\limsup_{\\sigma}5"), 144 | DemoText("\\sum_{n=1}^{\\infty}\\frac{1+n}{1-n}=\\bigcup_{A\\in\\Im}C\\cup B"), 145 | DemoText("\\sum_{n=1}^{\\infty}\\frac{1+n}{1-n}=\\bigcup_{A\\in\\Im}C\\cup B ", bb, left, z, text), 146 | DemoText("\\lim_{x\\to\\infty}\\frac{e^2}{1-x}=\\limsup_{\\sigma}6", bb, left, z, text), 147 | DemoText("\\int_{0}^{\\infty}e^x \\,dx=\\oint_0^{\\Delta}5\\Gamma"), 148 | DemoText("\\int\\int\\int^{\\infty}\\int_0\\int^{\\infty}_0\\int"), 149 | DemoText("U_3^2UY_3^2U_3Y^2f_1f^2ff"), 150 | DemoText("\\notacommand"), 151 | DemoText("\\sqrt{1}"), 152 | DemoText("\\sqrt[|]{1}"), 153 | DemoText("{n \\choose k}"), 154 | DemoText("{n \\choose k} ", bb, left, z, text), 155 | DemoText("\\left({n \\atop k}\\right)"), 156 | DemoText("\\left({n \\atop m}\\right) ", bb, left, z, text), 157 | DemoText("\\underline{xyz}+\\overline{abc}", bb, left, z, text), 158 | DemoText("\\underline{\\frac12}+\\overline{\\frac34}", bb, left, z, text), 159 | DemoText("\\underline{x^\\overline{y}_\\overline{z}+5}", bb, left, z, text), 160 | DemoText("\\int\\!\\!\\!\\int_D dx\\,dy", bb, left, z, text), 161 | DemoText("\\int\\int_D dxdy", bb, left, z, text), 162 | DemoText("y\\,dx-x\\,dy", bb, left, z, text), 163 | DemoText("y dx - x dy", bb, left, z, text), 164 | DemoText("hello\\ from \\quad the \\qquad other\\ side"), 165 | DemoText("\\vec x \\; \\hat y \\; \\breve {x^2} \\; \\tilde x \\tilde x^2 x^2 "), 166 | DemoText("\\hat{xyz} \\; \\widehat{xyz}\\; \\vec{2ab}"), 167 | DemoText("\\colorbox{#f0f0e0}{\\sqrt{1+\\colorbox{#d0c0d0}{\\sqrt{1+\\colorbox{#a080c0}{\\sqrt{1+\\colorbox{#7050a0}{\\sqrt{1+\\colorbox{403060}{\\colorbox{#102000}{\\sqrt{1+\\cdots}}}}}}}}}}}"), 168 | DemoText("\\begin{bmatrix} a & b\\\\ c & d \\\\ e & f \\\\ g & h \\\\ i & j\\end{bmatrix}"), 169 | DemoText("x {\\scriptstyle y} z"), // problem here 170 | DemoText("x \\mathrm x \\mathbf x \\mathcal X \\mathfrak x \\mathsf x \\bm x \\mathtt x \\mathit \\Lambda \\cal g"), 171 | DemoText("\\mathrm{using\\ mathrm}" ), 172 | DemoText("\\text{using text}", bb, left, z, text), 173 | DemoText("\\text{Mary has }\\$500 + \\$200."), 174 | DemoText("\\colorbox{#888888}{\\begin{pmatrix} \\colorbox{#ff0000}{a} & \\colorbox{#00ff00}{b} \\\\ \\colorbox{#00aaff}{c} & \\colorbox{#f0f0f0}{d} \\end{pmatrix}}", bb, left, z, text), 175 | DemoText("\\underline{xyz}+\\overline{abc}", bb, left, z, text), 176 | DemoText("\\underline{\\frac12}+\\overline{\\frac34}", bb, left, z, text), 177 | DemoText("\\underline{x^\\overline{y}_\\overline{z}+5}", bb, left, z, text), 178 | DemoText("\\int\\!\\!\\!\\int_D dx\\,dy", bb, left, z, text), 179 | DemoText("\\int\\int_D dxdy", bb, left, z, text), 180 | DemoText("y\\,dx-x\\,dy", bb, left, z, text), 181 | DemoText("y dx - x dy", bb, left, z, text), 182 | ] 183 | } 184 | 185 | let chars = 186 | """ 187 | \\text{ABCDEFGHIJKLMOPQRSTUVWXYZ} \\\\ 188 | \\text{abcdefghijklmnopqrstuvwxyz 0123456789} \\\\ 189 | \\text{<>?.,+-[]\\{\\}|=\\_()*\\%\\$!@\\#} 190 | """ 191 | 192 | var body: some View { 193 | ScrollView([.vertical,.horizontal]) { 194 | VStack { 195 | if previewFonts { 196 | // Display fonts 197 | ForEach(MathFont.allCases) { id in 198 | VStack(alignment: .leading) { 199 | Text("Font: **\(id.rawValue)**").font(.title3) 200 | MathView(equation: chars, font:id, 201 | textAlignment: .left, fontSize: 15) 202 | .padding(.bottom, 10) 203 | } 204 | } 205 | } 206 | 207 | // Change this to view a different font 208 | // Note: 209 | // Asana has problems with large braces 210 | // Euler has problems with large radicals and determants 211 | // kpMathLightFont has problems with large radicals and braces 212 | // kpMathSansFont has problems with large radicals and braces 213 | let font = MathFont.latinModernFont 214 | 215 | // Display example equations 216 | ForEach(demoLabels, id: \.self) { label in 217 | MathView(equation:label, font: font) 218 | } 219 | ForEach(fancy()) { label in 220 | MathView(equation: label.s, font: font, textAlignment: label.a, fontSize: label.w, labelMode: label.m, insets: label.i) 221 | .background(label.c) 222 | } 223 | } 224 | } 225 | .padding() 226 | } 227 | } 228 | 229 | struct ContentView_Previews: PreviewProvider { 230 | static var previews: some View { 231 | ContentView() 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /SwiftMathDemo/MathView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MathView.swift 3 | // TestMathView 4 | // 5 | // Created by Mike Griebling on 2022-02-14. 6 | // 7 | 8 | import SwiftUI 9 | import SwiftMath 10 | 11 | #if os(iOS) 12 | struct MathView: UIViewRepresentable { 13 | var equation: String 14 | var font: MathFont = .latinModernFont 15 | var textAlignment: MTTextAlignment = .center 16 | var fontSize: CGFloat = 30 17 | var labelMode: MTMathUILabelMode = .text 18 | var insets: MTEdgeInsets = MTEdgeInsets() 19 | 20 | func makeUIView(context: Context) -> MTMathUILabel { 21 | let view = MTMathUILabel() 22 | return view 23 | } 24 | func updateUIView(_ view: MTMathUILabel, context: Context) { 25 | view.latex = equation 26 | view.font = MTFontManager().font(withName: font.rawValue, size: fontSize) 27 | view.textAlignment = textAlignment 28 | view.labelMode = labelMode 29 | view.textColor = MTColor(Color.primary) 30 | view.contentInsets = insets 31 | } 32 | } 33 | #else 34 | struct MathView: NSViewRepresentable { 35 | var equation: String 36 | var font: MathFont = .latinModernFont 37 | var textAlignment: MTTextAlignment = .center 38 | var fontSize: CGFloat = 30 39 | var labelMode: MTMathUILabelMode = .text 40 | var insets: MTEdgeInsets = MTEdgeInsets() 41 | 42 | func makeNSView(context: Context) -> MTMathUILabel { 43 | let view = MTMathUILabel() 44 | return view 45 | } 46 | 47 | func updateNSView(_ view: MTMathUILabel, context: Context) { 48 | view.latex = equation 49 | view.font = MTFontManager().font(withName: font.rawValue, size: fontSize) 50 | view.textAlignment = textAlignment 51 | view.labelMode = labelMode 52 | view.textColor = MTColor(Color.primary) 53 | view.contentInsets = insets 54 | } 55 | } 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /SwiftMathDemo/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /SwiftMathDemo/README.md: -------------------------------------------------------------------------------- 1 | # SwiftMathDemo 2 | 3 | `SwiftMathDemo` demonstrates the use of [SwiftMath](https://github.com/mgriebling/SwiftMath.git) within a traditional 4 | storyboard controlled by a viewcontroller. Code is entirely written in Swift (except for the `SwiftMath` package). 5 | This demo is free of alien pods and the ensuing magical incantations that everyone hates. 6 | This same demo, although in Objective-C, is available from [iosMath](https://travis-ci.org/kostub/iosMath) (with alien pods). 7 | 8 | To use `SwiftMath` in your own code, just add the following package path to XCode: https://github.com/mgriebling/SwiftMath.git 9 | 10 | ## Examples 11 | Here are screenshots of an iPad, iPhone, and Mac(catalyst) running the demo: 12 | 13 | ![iPad Screenshot](images/iPad.png) 14 | 15 | ![iPhone Screenshot](images/iPhone.png) 16 | 17 | ![Quadratic Formula](images/iMac.png) 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /SwiftMathDemo/SwiftMathDemo.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.files.user-selected.read-only 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SwiftMathDemo/SwiftMathDemoApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftMathDemoApp.swift 3 | // SwiftMathDemo 4 | // 5 | // Created by Mike Griebling on 2023-01-18. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct SwiftMathDemoApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SwiftMathDemo/images/iMac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/SwiftMathDemo/images/iMac.png -------------------------------------------------------------------------------- /SwiftMathDemo/images/iPad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/SwiftMathDemo/images/iPad.png -------------------------------------------------------------------------------- /SwiftMathDemo/images/iPhone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/SwiftMathDemo/images/iPhone.png -------------------------------------------------------------------------------- /images/darkiMac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/images/darkiMac.png -------------------------------------------------------------------------------- /images/darkiPad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/images/darkiPad.png -------------------------------------------------------------------------------- /images/darkiPhone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/images/darkiPhone.png -------------------------------------------------------------------------------- /images/lighiPhone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/images/lighiPhone.png -------------------------------------------------------------------------------- /images/lightiMac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/images/lightiMac.png -------------------------------------------------------------------------------- /images/lightiPad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mgriebling/SwiftMathDemo/55391be142e5a7d2f87066c21e305d624bbbf1c6/images/lightiPad.png --------------------------------------------------------------------------------