美文网首页
even-odd(奇偶原则)Apple文档

even-odd(奇偶原则)Apple文档

作者: pluskok | 来源:发表于2020-05-08 15:45 被阅读0次

https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/dq_paths.html#//apple_ref/doc/uid/TP30001066-CH211-TPXREF106

奇偶规则

- (void)drawRect:(CGRect)rect{
    CGContextRef ref = UIGraphicsGetCurrentContext();
    
    CGContextAddRect(ref, CGRectMake(300, 300, -200, -200));
    CGContextAddRect(ref, CGRectMake(250, 250, -100, -100));

    CGContextDrawPath(ref, kCGPathEOFill);
}
Simulator Screen Shot - iPhone SE (2nd generation) - 2020-05-08 at 16.10.06.png

非零环绕规则

- (void)drawRect:(CGRect)rect{
    CGContextRef ref = UIGraphicsGetCurrentContext();
    CGPoint outter_points[4] = {{100,100},{100,300},{300,300},{300,100}};
    CGContextAddLines(ref, outter_points, 4);
    
    CGPoint inner_points[4] = {{150,150},{250,150},{250,250},{150,250}};
    CGContextAddLines(ref, inner_points, 4);
    
//    CGContextFillPath(ref);
        
//    裁剪图片
    CGContextClip(ref);
    UIImage* image = [UIImage imageNamed:@"me"];
    [image drawInRect:rect];

}
Simulator Screen Shot - iPhone SE (2nd generation) - 2020-05-08 at 16.15.12.png

相关文章

网友评论

      本文标题:even-odd(奇偶原则)Apple文档

      本文链接:https://www.haomeiwen.com/subject/dsifnhtx.html