CGContextAddArcToPoint和CGContextAddArc

来源:互联网 发布:游戏超人软件 编辑:程序博客网 时间:2024/04/29 22:21

转载:http://blog.csdn.net/xiazailushang/article/details/12047137 此处是转载,非常感谢作者分享的知识

比较难的是CGContextAddArcToPoint  

代码如下:

[plain] view plaincopy
  1. CGContextRef context=UIGraphicsGetCurrentContext();  
  2. CGContextSetRGBStrokeColor(context,1,0,0,1);  
  3. CGContextMoveToPoint(context,150,50);  
  4. CGContextAddLineToPoint(context,100,80);  
  5. CGContextAddLineToPoint(context,130,150);  
  6.   
  7. CGContextMoveToPoint(context,150,50);//圆弧的起始点  
  8. CGContextAddArcToPoint(context,100,80,130,150,50);  
  9. CGContextStrokePath(context);  

CGContextMoveToPoint(context,150,50);//圆弧的起始点

CGContextAddArcToPoint(context,100,80,130,150,50);

是说从(15050)到(10080)画一条线,然后再从(10080)到(130150)画一条线,从这两条线(无限延伸的) 和半径50可以确定一条弧,

 

CGContextAddArc(context, 100, 100, 30, 0, M_PI, 1);  add by me :由x,y可确定圆心坐标,而0,0角度位于圆心的正下方。

比较简单了,(100,100)为圆心的坐标,30为半径,(0M_PI)为起始角度和结束角度,1为顺时针,为逆时针

是说从(15050)到(10080)画一条线,然后再从(10080)到(130150)画一条线,从这两条线(无限延伸的) 和半径50可以确定一条弧


0 0
原创粉丝点击