From 391701fdc7af7c699bcb2fe9af8aafa8ded72be5 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 22 Oct 2012 15:02:28 +0100 Subject: [PATCH] `- CPBezierPath addClip` and `setClip`. This enables e.g. a `CPGradient` to be drawn clipped by an arbitrary bezier path. --- AppKit/CPBezierPath.j | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AppKit/CPBezierPath.j b/AppKit/CPBezierPath.j index 213a61e96..c6633ce97 100644 --- a/AppKit/CPBezierPath.j +++ b/AppKit/CPBezierPath.j @@ -306,4 +306,21 @@ var DefaultLineWidth = 1.0; _path = CGPathCreateMutable(); } +- (void)addClip +{ + var ctx = [[CPGraphicsContext currentContext] graphicsPort]; + + CGContextAddPath(ctx, _path); + CGContextClip(ctx); +} + +- (void)setClip +{ + var ctx = [[CPGraphicsContext currentContext] graphicsPort]; + + CGContextBeginPath(ctx); + CGContextAddPath(ctx, _path); + CGContextClip(ctx); +} + @end