Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


This repository is a part of Loose Leaf.

In line with Sylion's work philosophy the design has been developed to greatly simplify the complexity of the code and maximizing the recycling of classes, as well as providing great ways for their extension.

The application comprises four new classes: SYVectorView, SYFreePaintView, SYGeometricMathController y SYGeometry. Following the design pattern MVC (Model View Controller), the SYFreePaintView class recieves taps from the user and sends them to the controller, namely SYGeometricMathController. The controller manages the data received from SYFreePaintView storing it until the user finishes the gesture lifting the finger from the iPad's screen. At that moment the SYGeometricMathController analyzes the result using the algorithms explained further, obtaining the figure that is ment to be represented. Once it finishes the analysis of the figure to be represented it sends an order to the class SYVectorView so it can draw it. SYVectorView will take care of displaying the finalized figure, drawing it as a vector shape. The way in wich SYGeometricMathController communicates with SYVectorView is using the object SYGeometry. This object contains the needed parameters for the resulting figure's geometry to be displayed, such as trace color, fill color, kind of shape...


In the following sección we explain the used algorithm in very simple terms so it's easily undersood. The algorithm analyzes XY point sequence from the user's input during the gesture. These points are stored by the controller and are analyzed taking into account three key areas:

  • Maximum and minimum positions.
  • Angles between adjacent points.
  • Direction changes between points close in the list.


If we analyze the geometry of the square, rhombus and circle we notice that the relative position of maximums and minimums in the XY coordinate axis are different. The rhombus and circle contain their maximums in the middle point of the imaginary square that covers them, while the square has its maximums and minimums in each of its vertex. This feature is therefore very useful when we try to distinguish squares from circles or rhombus.


The controller also calculates the existing angles between a sequence of points in a path. If the angle in a three point sequence is around 180° it is known that the user is tracing a straight line. If by contrast these angles are inferior to an approximate value of 140° you can infer that the user is drastically changing the direction in the trace. This feature shows in a useful way the number of resulting vertices the figure could have.


Just as we did with the angles SYGeometricMathController analyzes the point list and infers how they vary in the XY positions for each point regarding the previous. This reveals abrupt direction changes. Either the square or rhombus show abrupt direction changes while, in a properly traced circle, direction changes are gentle and progressive.


The following values have been empirically obtained with successive trials in drawings by different users. It's known that for angle variations of zero or close to zero the figure has a high probability of being a circle. On the other hand, for changes in direction superior to eight it could be said with high probability that the figure to be drawn is a rhombus. For angle and direction values between two and five figure identification becomes less accurate or with an inferior chance of success.


Simplify and smooth UIBezierPaths by reducing the number of elements within the path.






No releases published

Sponsor this project



No packages published