I've been doing some shape drawing using Swift's built in drawing tools to draw simple paths with straight lines. One anomaly I've noticed is that if you want a path that is filled but does not have a line stroke on its edge, it renders without antialiasing and has a rough appearance. In contrast, a line by default always renders smoothly. There is an option to turn antialiasing on but this also makes no difference. I could just make the stroke the same colour as the fill, but this means that the edge expands outwards from the point positions that define the shape.
//creates shape node to contain path
let myTriangle = SKShapeNode()
//declares path object
let myPath = CGPathCreateMutable()
//moves to starting point of shape
CGPathMoveToPoint(myPath, nil, -50, 0)
//draws lines of shape
CGPathAddLineToPoint(myPath, nil, 0, 100 )
CGPathAddLineToPoint(myPath, nil, 50, 0 )
CGPathAddLineToPoint(myPath, nil, -50, 0 )
//closes path
CGPathCloseSubpath(myPath)
myTriangle.antialiased = true
//adds path to shape node
myTriangle.path = myPath
//sets fill colour and zero line width
myTriangle.fillColor = SKColor.blueColor()
myTriangle.lineWidth = 0
//sets antialiasing
myTriangle.antialiased = true
//sets position in parent object and adds node
myTriangle.position = CGPointMake(600, 600)
self.addChild(myTriangle)
Any ideas?
Many thanks, Kw