MyException - 我的异常网
当前位置:我的异常网» 移动开发 » paths 拾掇

paths 拾掇

www.MyException.Cn  网友分享于:2013-04-03  浏览:5次
paths 整理

1. 向量绘制,用路径来描述图形,可以是闭合也可以不是闭合。

2. Building Blocks:

- 点: CGContextMoveToPoint

-线: CGContextAddLineToPoint, CGContextAddLines

-圆弧:CGContextAddArc,CGContextAddArcToPoint

-曲线:Quadratic/Cubic Bezier曲线, CGContextAddCurveToPoint, CGContextAddQuadCurveToPoint

- CGContextClosePath会被某些操作默认执行。

- 椭圆:CGContextAddEllipseInRect;

- 矩形: CGContextAddRect;

3. 创建Path CGContextBeginPath + CGContextMoveToPoint

4. Painting Path != Create Path

5. Mutable Path: Path对象,独立于Context存在。CGContextAddPath来使用它。

- CGPathCreateMutable = CGContextBeginPath

- CGPathMoveToPoint = CGContextMoveToPoint

- CGPathAddLineToPoint = CGContextAddLineToPoint

- CGPathAddCurveToPoint = CGContextAddCurveToPoint

- CGPathAddEllipseInRect = CGContextAddEllipseInRect

- CGPathAddArc = CGContextAddArc

- CGPathAddRect = CGContextAddRect

- CGPathCloseSubPath = CGContextCloseSubPath

6. 描边

- 线宽:

- 连接方式:Miter尖角,Round圆角,Bevel平角

- 线头:Butt平头,Round圆头,Projecting扩展平头

- 角限:限制尖角连接的范围

- 点划模板:

- 颜色空间:

- 颜色:

- StrokePattern?

CGContextStrokePath/CGContextStrokeRect/CGContextStrokeRectWithWidth/CGContextStrokeEllipseInRect/CGContextStrokeLineSegment/CGContextDrawPath

7.填充规则:

- nonzero winding:CGContextFillPath从某点出发向图形边缘做一条射线,如果射线和图形某条边相交,且该边从坐向右穿过射线,则相交计数+1,如果该边从右向左穿过射线,则相交计数-1。如果最后相交计数为1,则该点在图形内。

- even odd:CGContextEOFillPath从某点出发向图形边缘做一条射线,如果射线和图形边相交点数为奇数,则该点在图形内。

8. CGContextFillPath/CGContextEOFillPath/CGContextFillRect/CGContextFillRects/CGContextFillEllipseInRect/CGContextDrawPath

9. 混合:CGContextSetBlendMode - GraphicsState, 通常:

- Normal: result  = result = (alpha*fore) + (1.0-alpha)*back;

- Multiply: result = fore*back;

- Screen: result = 1.0-(1.0-fore)*(1.0-back);

- Overlay: result = gray(back)>0.5?(1.0-2.0*(1.0-back)*(1.0-fore):fore*back*2.0f;

- Darken: result = min(fore,back);

- Lighten: result = max(fore,back);

- Color Dodge: result = back/(1.0-fore);

- Color Burn: result = 1.0 - (1.0-back)/fore;

- Soft Light: result = gray(fore)>0.5? 1.0 - (1.0-back)*(1.5 - fore):back*(fore+0.5);

- Hard Light: result = gray(fore)>0.5?1.0 - 2.0*(1.0-back)*(1.0-fore):2.0*back*fore;

- Difference: result = abs(fore-back);

- Exclusion: result = 0.5 - 2.0*(fore - 0.5)*(back-0.5);

- Hue: result = lum(back), sat(back),hue(fore);

- Saturtation: result = lum(back),sat(fore),hue(back);

- Color: result = lum(back),sat(fore),hue(fore);

- Luminosity: result = lum(fore),sat(back),hue(back);

10.裁剪: CGConextClip/CGContextEOClip/CGContextClipToRect/CGContextClipToRects/CGContextClipToMask;


1. CGContext类。

2. UIView::DrawRect函数

3. UIGraphicsGetCurrentContext()函数

4. UIView坐标系和Quartz坐标系相反。

5. CGContextRef myContext = [[NSGraphicsContext currentContext] graphicsPort];

6. initWithFrame, intWithCoder, DrawRect

7. CGPDFContextCreateWithURL, CGPDFContextCreate

CFURLCreateWithFileSystemPath(), CGDataConsumerCreateWithURL()

8. iOS 推荐使用 UIGraphicsBeginImageContextWithOptions,它会自动做Quartz和UIKit之间的坐标变换。

9. CGBitmapContextCreate

10. Pixel Format

NULL color space:

- kCGImageAlphaoOnly 8bpp = A8

Gray color space:

- kCGImageAlphaNone 8bpp = L8

- kCGImageAlphaOnly 8bpp = A8

- kCGImageAlphaNone 16bpp = L16

- KCGImageAlphaNone|kCGBitmapfloatComponents = L32F

RGB color space:

- kCGImageAlphaNoneSkipFirst, 16bpp, 5bpc = R5G5B5X1

- kCGImageAlphaNoneSkipFirst, 32bpp, 8bpc = R8G8B8X8

- kCGImageAlphaNoneSkipLast, 32bpp, 8bpc = X8R8G8B8

- kCGImageAlphaPremultipliedFirst, 32bpp, 8bpc = R8G8B8A8

- kCGImageAlphaPremultipliedLast, 32bpp, 8bpc = A8R8G8B8

- kCGImageAlphaPremultipledLast, 64bpp, 16bpc = A16R16G16B16

- kCGImageAlphaNonSkipLast, 64bpp, 16bpc = X16R16G16B16

- kCGImageAlphaNoneSkipLast|kCGBitmapFloatComponents, 128bpp, 32bpc = X32R32G32B32F

- kCGImageAlphaPremultipliedLast | kCGBitmapFloatComponents, 128bpp, 32bpc = A32R32G32B32F

CMYK space:

- kCGImageAlphaNone 32bpp, 8bpc = C8M8Y8K8

- kCGImageAlphaNone 64bpp, 16bpx = C16M16Y16K16

- kCGImageAlphaNone|kCGBitmapFloatComponents = C32M32Y32K32F

11. CGContextSetShouldAntialias for bitmap context, CGContextSetAllowAntialasing for graphics context.


文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有