On iOS, if we do
CGContextMoveToPoint(contextFoo, 0, 0);
CGContextAddLineToPoint(contextFoo, x, y);
CGContextAddLineToPoint(contextFoo, x2, y2);
// ... and many more CGContextAddLineToPoint
then after this, if we do a CGContextStrokePath, we will get an outline, or if we CGContextFillPath, we get the “fill”, but we can’t do both, because after a stroke or a fill, the “current path” is gone. How can we both fill and stroke a path (such as wanting a yellow fill and orange outline)?
We can move the MoveTo and AddLine calls to a function, and call that function, do a fill, and call the function again, and do a stroke, but there are many x and y that makes passing all of them to the function quite troublesome. What might be some ways to do this?
you can save your Path btw (to reuse it for multiple things of same shape) using:
CGPathBeginPath/MoveToPoint/AddLine/… very similar to CGContext/…
For your example: