## Swift 3.0 Card Generator: Update

Early November 2016, I pushed up a small pet project to GitHub: https://github.com/Zbeyer/CardGenerator

The application is simple: enter a few bits of information, choose a color, and set a background image and it formats a trading card. The dpi generated is not yet tweaked to work with the chosen distribution method (final TODO) but a few branches exist with slight variations on configuration.

here are some examples using background images from my static art portfolio:

## Swift Clock Final*

### Final Version of the Birthday Swift Clock Project

Download Zip: clockmodulev3.zip

Source…

## Swift: Clock Layout Update*

While yesterday’s code solved the ‘problem’, today I took a few minutes to do some abstraction and write an alternate version that computes the positions of n points evenly spaced in a circle:

``````
//Constant size of each node on the clock face
let kSize:CGFloat = 4

//Place a ClockFace node in the center
let clockFace:SKShapeNode = nodeGenerator(size:r, point: CGPoint( x:midPoint.x, y:midPoint.y), scene:scene)
clockFace.fillColor = SKColor.gray

//Place a normal node in the center
let centerNode:SKShapeNode = nodeGenerator(size:kSize, point: CGPoint( x:midPoint.x, y:midPoint.y), scene:scene)

//Determine radian spacing...
let nodesOnTheClock = 12
let interval:Double = 2 * M_PI / Double(nodesOnTheClock) //Radians

for index in 1...nodesOnTheClock {
let angle:Double = M_PI_2 - Double(index) * interval
let node:SKShapeNode = nodeGenerator(size: kSize,
point: CGPoint(
x:midPoint.x + r * cos(CGFloat(angle)),
y:midPoint.y + r * sin(CGFloat(angle))),
scene:scene)

}
``````

You can grab the Gist at: https://gist.github.com/Zbeyer/038b672ba619ea93a06c1ed49608731c

The Full Code Snippet will be below the following screenshots:

## Clock Points — Swift Playground

### Another Quick Exercise

For my birthday, I decided to solve a display exercise in Swift that inevitably will be necessary in my personal Towne of Klock project. The problem is very simple:

Given a 2D cartesian plane (in this case a SpriteKit Scene in Swift) determine where the points for One O’Clock through Twelve O’Clock must be placed. Not a very original or difficult problem to solve, per say. However, I do so love playing with geometry!

If interested in my solution you can do one of the following…

## iOS GameKit (Swift) Controller

### A Leisurely Evening Exercise

Tonight I decided to Explore SpriteKit. I decided a quick project would be to create a simple touch controller (using a gamepad control stick as a metaphor). I drew most of the inspiration for this project from the iOS Chrono Trigger port which I always enjoyed.

## Inspecting Headers with Objective-C

Occasionally, an iOS app may to need to parse the headers out of an HTTP request. Here is one example to implement such behavior.

First consider the NSHTTPURLResponse Object:

``````<NSHTTPURLResponse: 0x79f4b7e0>
{
URL: http://zbeyer.com/stuff/mobile-testing/index.html
}
{
status code: 200,
headers {
"Accept-Ranges" = bytes;
Age = 157;
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 94;
"Content-Type" = "text/html";
Date = "Mon, 06 Jun 2016 21:20:29 GMT";
"Last-Modified" = "Mon, 06 Jun 2016 18:36:03 GMT";
Server = "nginx/1.10.1";
Vary = "Accept-Encoding";
}
}
``````

For this example, I am interested in the “Last Modified” header field on my sample index.html file. My application wants to know how long it’s been since that url was last updated.

## draw.io : The Best Free Flowchart Software

Draw.io

Three to six months ago I found the flowchart software called draw.io. I have lauded it for it’s easy drag / drop behavior for generating rich flowcharts, schemes, and UI mocks. The application is designed to sync to a Google Drive (google doc api) account and offers all the fun sharing & collaboration features that I have come to expect from a cloud application. I have not had the opportunity to try out the Jira or Confluence integration yet–so I cannot give any advice or review there.

MVC Architecture

Diagrams generated can be exported in a variety of image formats (JPG, PNG, etc), SVG, XML and PDF (which I haven’t tried or found a use for yet), or HTML–which generates a static webpage that can be used on desktop browsers (see the following examples):

sample flowchart

Sample Diagram

MCFTB – Play Strategy

I love this tool.