自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iOS畫圖總結(jié)

移動(dòng)開發(fā) iOS
本文為各位讀者引出了iOS開發(fā)中各種畫圖方法,并做了簡(jiǎn)要的描述,希望對(duì)各位網(wǎng)友有所幫助。

0 CGContextRef context = UIGraphicsGetCurrentCont ext(); 設(shè)置上下文
1 CGContextMoveToPoint 開始畫線
2 CGContextAddLineToPoint 畫直線

4 CGContextAddEllipseInRec t 畫一橢圓
4 CGContextSetLineCap 設(shè)置線條終點(diǎn)形狀
4 CGContextSetLineDash 畫虛線
4 CGContextAddRect 畫一方框
4 CGContextStrokeRect 指定矩形
4 CGContextStrokeRectWithW idth 指定矩形線寬度
4 CGContextStrokeLineSegme nts 一些直線

5 CGContextAddArc 畫已曲線 前倆店為中心 中間倆店為起始弧度 最后一數(shù)據(jù)為0則順時(shí)針畫 1則逆時(shí)針
5 CGContextAddArcToPoint(context,0,0, 2, 9, 40);//先畫倆條線從point 到 弟1點(diǎn) , 從弟1點(diǎn)到弟2點(diǎn)的線    切割里面的圓
6 CGContextSetShadowWithCo lor 設(shè)置陰影
7 CGContextSetRGBFillColor  這只填充 顏色
7 CGContextSetRGBStrokeCol or 畫筆顏色設(shè)置
7 CGContextSetFillColorSpa ce 顏色空間填充
7 CGConextSetStrokeColorSp ace 顏色空間畫筆設(shè)置
8 CGContextFillRect 補(bǔ)充當(dāng)前填充顏色的rect
8 CGContextSetAlaha 透明度

9 CGContextTranslateCTM 改變畫布位置
10 CGContextSetLineWidth 設(shè)置線的寬度
11 CGContextAddRects 畫多個(gè)線
12 CGContextAddQuadCurveToP oint 畫曲線
13 CGContextStrokePath 開始繪制 圖片
13 CGContextDrawPath 設(shè)置繪制模式
14 CGContextClosePath 封閉當(dāng)前線路
15 CGContextTranslateCTM(context, 0, rect.size.height);        CGContextScaleCTM(context, 1.0, -1.0);反轉(zhuǎn)畫布
16 CGContextSetInterpolatio nQuality 背景內(nèi)置顏色質(zhì)量等級(jí)
16 CGImageCreateWithImageIn Rect 從原圖片中取小圖
17  字符串的寫入可用Nsstring本身的畫圖方法 - (CGSize)drawInRect:(CGRect)rect withFont:(UIFont *)font lineBreakMode:(UILineBreakMode)lineBreakMode alignment:(UITextAlignment)alignment;來(lái)寫進(jìn)去即可
18對(duì)圖片放大縮小的功能就是慢了點(diǎn)
UIGraphicsBeginImageCont ext(newSize);
UIImage* newImage = UIGraphicsGetImageFromCu rrentImageContext();
UIGraphicsEndImageContex t();

19 CGColorGetComponents() 返回顏色的各個(gè)值 以及透明度可用只讀const float 來(lái)接收是個(gè)數(shù)組

20 畫圖片 CGImageRef  image =CGImageRetain(img.CGImage);
         CGContextDrawImage(context, CGRectMake(10.0,  height  -                           
         100.0, 90.0, 90.0), image);

21 實(shí)現(xiàn)逐變顏色填充方法 CGContextClip(context);
        CGColorSpaceRef rgb = CGColorSpaceCreateDevice RGB();
        CGFloat colors[] =
        {
                204.0 / 255.0, 224.0 / 255.0, 244.0 / 255.0, 1.00,
                29.0 / 255.0, 156.0 / 255.0, 215.0 / 255.0, 1.00,
                0.0 / 255.0,    50.0 / 255.0, 126.0 / 255.0, 1.00,
        };
        CGGradientRef gradient = CGGradientCreateWithColo rComponents           
     (rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4));
        CGColorSpaceRelease(rgb);       
        CGContextDrawLinearGradi ent(context, gradient,CGPointMake       
     (0.0,0.0) ,CGPointMake(0.0,self.frame.size.height),                                       
         kCGGradientDrawsBeforeSt artLocation);
       
22 注:   畫完圖后,必須
先用CGContextStrokePath來(lái)描線,即形狀
后用CGContextFillPath來(lái)填充形狀內(nèi)的顏色.

填充一個(gè)路徑的時(shí)候,路徑里面的子路徑都是獨(dú)立填充的。
假如是重疊的路徑,決定一個(gè)點(diǎn)是否被填充,有兩種規(guī)則
1,nonzero winding number rule:非零繞數(shù)規(guī)則,假如一個(gè)點(diǎn)被從左到右跨過(guò),計(jì)數(shù)器+1,從右到左跨過(guò),計(jì)數(shù)器-1,最后,如果結(jié)果是0,那么不填充,如果是非零,那么填充。
2,even-odd rule: 奇偶規(guī)則,假如一個(gè)點(diǎn)被跨過(guò),那么+1,最后是奇數(shù),那么要被填充,偶數(shù)則不填充,和方向沒(méi)有關(guān)系。

Function
Description 
CGContextEOFillPath
使用奇偶規(guī)則填充當(dāng)前路徑
CGContextFillPath
使用非零繞數(shù)規(guī)則填充當(dāng)前路徑
CGContextFillRect
填充指定的矩形
CGContextFillRects
填充指定的一些矩形
CGContextFillEllipseInRe ct
填充指定矩形中的橢圓
CGContextDrawPath
兩個(gè)參數(shù)決定填充規(guī)則,kCGPathFill表示用非零繞數(shù)規(guī)則,kCGPathEOFill表示用奇偶規(guī)則,kCGPathFillStroke表示填充,kCGPathEOFillStroke表示描線,不是填充

設(shè)置當(dāng)一個(gè)顏色覆蓋上另外一個(gè)顏色,兩個(gè)顏色怎么混合
默認(rèn)方式是
result = (alpha * foreground) + (1 - alpha) * background

CGContextSetBlendMode :設(shè)置blend mode.
CGContextSaveGState :保存blend mode.
CGContextRestoreGState:在沒(méi)有保存之前,用這個(gè)函數(shù)還原blend mode.
CGContextSetBlendMode 混合倆種顏色

責(zé)任編輯:閆佳明 來(lái)源: oschina
相關(guān)推薦

2013-09-12 15:37:09

iOS開發(fā)流程

2015-09-23 10:14:48

iOS 代碼實(shí)踐

2014-11-04 10:38:13

iOS圖形

2015-01-15 16:45:05

iOS源碼自定義畫圖

2013-03-28 09:45:34

iOS學(xué)習(xí)筆記總結(jié)整理

2012-12-24 13:38:01

iOSUIView

2013-04-01 17:05:28

2017-01-19 21:45:27

iOS開發(fā)者賬號(hào)

2014-06-10 14:19:52

iOSUIApplicati總結(jié)

2018-03-07 11:19:53

iOS面試代碼

2013-09-09 15:49:44

iOS應(yīng)用內(nèi)置付費(fèi)IAP設(shè)置總結(jié)

2014-03-12 10:13:00

iOSSEL對(duì)象

2021-08-10 13:50:24

iOS

2013-01-06 09:52:43

SQLite

2013-04-09 16:04:06

iOS開發(fā)SQLite知識(shí)總結(jié)

2014-08-04 14:19:00

iOS通知中心擴(kuò)展

2016-03-03 10:07:39

ios內(nèi)存管理面試總結(jié)

2010-08-03 09:54:09

路由器IOS

2013-07-25 14:12:53

iOS開發(fā)學(xué)習(xí)UITableView

2013-09-09 16:11:16

iOS應(yīng)用內(nèi)置付費(fèi)IAP總結(jié)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)