DaveS
1
my app contains this code
public func drawPieSlice(_ rect:CGRect,startAngle:CGFloat,endAngle:CGFloat,fill:Bool=false) {
let r = adjRect(rect)
let center : CGPoint = CGPoint(x: r.midX,y: r.midY)
let radius : CGFloat = min(r.width,r.height)/2
let path = UIBezierPath(circleSegmentCenter: center, radius: radius, startAngle: startAngle, endAngle: endAngle)
if fill==true {
path.fill()
} else {
path.lineWidth = penSize
path.stroke()
}
}
What I would like to add is the ability to “clip” to the created path, and draw lines for cross hatching inside the defined area. Any ideas?
I used a rect in xojo for Clipped Pies… many years ago
DaveS
3
not sure how clipping to a rect is the same as clipping to a shape that is not a rect
maybe this ?
CGContextEOClip
sounds like it lets you modify the current clipping path with a new one
It should be so while the flexibility is needed for all dynamically changed graphics.
NSBeizerPath has a setClip function.
UIBezierPath has a addClip function which seems like it should do the same thing.
Failing that, you can get the CGPath, get the CGContext from the current NSGraphicsContext (or equivalent) and then use CGContextClipToPath
DaveS
7
AddClip was what did it… thanks