Alex Does Things Poorly

Alex does a variety of things poorly - swift, data science, datavis, ML, drawing, AR, unity, etc, etc.

25 August 2021

Project Meishi and Catmull-Rom splines

by alex

One more day of 100 Days of SwiftUI finished. Well, I finished the SwiftUI bits yesterday. I didn’t end up writing this today because I decided to try to figure out how to implement interpoloating splines in Swift. Yesterday I got discouraged and gave up after a frustrating try at it, but this morning, with fresh eyes, I was able to get it working.

Our SwiftUI project yesterday was basically a business card app. I called it Meishi, after the Japanese word for calling or visiting card. It was a bunch of work but nothing too challenging, and it definitely felt nice to be able to finish an app like that in just over an hour, even adding Core Data support. It reminded me of an interview challenge I did a few years back, where I floundered because I decided to implement it with Core Data, but then I couldn’t remember everything necessary to get a Core Data stack working within the interview time window. The new Persistence controller in the Core Data template in the Xcode beta certainly helps, but it’s also way easier to connect fetch requests to UI in SwiftUI. Not to mention, I’ve done three or four Core Data projects in the past few weeks so I’m feeling pretty confident.

For today’s image, I started with yet another moire sketch, from the Generative Design book. However, the sketch in the book uses a P5.js method called curveVertex that uses continuous interpolating splines under the hood. I wanted to do the same thing in Swift, but iOS has no built-in method for doing this. It took me a day or so, but I eventually got something working. I even managed to get it to work using the Accelerate framework, which is a first for me. This image uses an implementation before I got interpolating splines working, because I like the way the moire looks with more jitter.

Drawing with Moire

tags: swift - swiftui - generative-art