Creating a Geometric Path from 2D points without a graphics context. Possible in iOS?

StackOverflow https://stackoverflow.com/questions/17057540

  •  31-05-2022
  •  | 
  •  

Вопрос

I am needing a way to test out some heavy mathematical functionality in my code and have come to the point where I need to verify that such code is working properly. I would like to be able to create a path based on an array of points and use this path for testing without a graphics context.

As an example, Java has various classes such as the Path2D class that is completely independent on any kind of context or view unless you need to display the information in some kind of graphics context.

It looks like that Apple doesn't provide any methods that allow you to create, manipulate and change arbitrary geometric shapes but I wanted to come here and make sure.

Это было полезно?

Решение

CGPath and UIBezierPath can both be created without having a current context. But it depends what you want to do as to how much use they will be because their purpose is really for drawing. As such it isn't really easy to get the points back from the path once added.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top