Using Swift techniques for Drawing

The long discussion on is Code an Art or a Science will continue for years to come because there will always be two sides to it and I am not attempting to join or fuel that discussion. However, I feel that in my lifetime I have been lucky to get exposure to a whole lot of technologies and development techniques over the past couple of decades. With that as a benchmark, I can say that Swift makes development a breeze and also in many ways turns your code into Art.
In this article, we are looking at using Swift for Drawing, not the one with oils and canvases, but drawing lines and curves. This can grow into a better library but for now it is about how code can look better and perform better too.

What are we trying to achieve

We are trying to create code to help us create a path which we can use as we would want. Generating the path is not difficult, but you will see that it makes it easy to use. Lets look at what it would look like,

Note: The syntax shown above is what is required by Swift 3.0, where you need to specify the first parameter.

this will result in a path that creates a triangle and a circle outside of it. which looks something like this.
Bezier Path

In Closing

While everyone enjoys a particular style of coding, I prefer the easy to read and simplistic approach to code. Something that can be easily modified or managed further by developers than create a complicated library that developers use but avoid touching for the fear of not understanding magic numbers and macros, etc.

It is just a matter of time when Swift will be everywhere and if you want to get future generations onto Swift, then it is on you to write simplistic code.

Views All Time
Views All Time
Views Today
Views Today
Posted in Basics, Tip and tagged , , , , , .