Linking

Capturing Life & Tech

  • 主页
  • 随笔
  • 关于我
所有文章 外链

Linking

Capturing Life & Tech

  • 主页
  • 随笔
  • 关于我

iOS绘图

阅读数:次 2017-06-01
字数统计: 722字   |   阅读时长≈ 3分

Path:路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//指定当前点为 current point,Quartz会跟踪current point一般执行完一个相关函数后,current point都会相应的改变。
CGContextMoveToPoint (
CGContextRef c,
CGFloat x,
CGFloat y
);

Lines:线
//从当前点 画到点,current point 会变化
void CGContextAddLineToPoint (
CGContextRef c,
CGFloat x,
CGFloat y
);
<!-- more -->

//添加多个路径
void CGContextAddLines (
CGContextRef c,
const CGPoint points[],
size_t count
);

Arcs:弧线

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
void CGContextAddArc (
CGContextRef c,
CGFloat x, //圆心的x坐标
CGFloat y, //圆心的y坐标
CGFloat radius, //圆的半径
CGFloat startAngle, //开始弧度
CGFloat endAngle, //结束弧度
int clockwise //0表示顺时针,1表示逆时针
);

void CGContextAddArcToPoint(
CGContextRef c,
CGFloat x1, //端点1的x坐标
CGFloat y1, //端点1的y坐标
CGFloat x2, //端点2的x坐标
CGFloat y2, //端点2的y坐标
CGFloat radius //半径
);

Curves
三次曲线函数
void CGContextAddCurveToPoint (
CGContextRef c,
CGFloat cp1x, //控制点1 x坐标
CGFloat cp1y, //控制点1 y坐标
CGFloat cp2x, //控制点2 x坐标
CGFloat cp2y, //控制点2 y坐标
CGFloat x, //直线的终点 x坐标
CGFloat y //直线的终点 y坐标
);

二次曲线函数
void CGContextAddQuadCurveToPoint (
CGContextRef c,
CGFloat cpx, //控制点 x坐标
CGFloat cpy, //控制点 y坐标
CGFloat x, //直线的终点 x坐标
CGFloat y //直线的终点 y坐标
);

画椭圆,矩形

1
2
3
4
5
6
7
8
9
10
void CGContextAddEllipseInRect (
CGContextRef context,
CGRect rect //一矩形
);

void CGContextAddRect (
CGContextRef c,
CGRect rect
);

Path:路径

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
CGContextMoveToPoint设置起点
CGContextClosePath 连接起点和当前点
CGPathCreateMutable 类似于 CGContextBeginPath
CGPathMoveToPoint 类似于 CGContextMoveToPoint
CGPathAddLineToPoint 类似于 CGContextAddLineToPoint
CGPathAddCurveToPoint 类似于 CGContextAddCurveToPoint
CGPathAddEllipseInRect 类似于 CGContextAddEllipseInRect
CGPathAddArc 类似于 CGContextAddArc
CGPathAddRect 类似于 CGContextAddRect
CGPathCloseSubpath 类似于 CGContextClosePath
CGContextAddPath函数把一个路径添加到graphics

路径填充和描边:
Stroking :画出路径
Filling :填充路径的封闭区域

路径和填充的效果

//配置样式
//笔触颜色
CGContextSetStrokeColorWithColor(context, [UIColor greenColor].CGColor);
//笔触宽度
CGContextSetLineWidth(context, 20);
//join 拐点样式
// enum CGLineJoin {
// kCGLineJoinMiter, //尖的,斜接
// kCGLineJoinRound, //圆
// kCGLineJoinBevel //斜面
// };
CGContextSetLineJoin(context, kCGLineJoinRound);

//Line cap 线的两端的样式
// enum CGLineCap {
// kCGLineCapButt,
// kCGLineCapRound,
// kCGLineCapSquare
// };
CGContextSetLineCap(context, kCGLineCapSquare);

//虚线线条样式
CGFloat lengths[] = {10,10};
CGContextSetLineDash(context, 0, lengths, 2);



//路径填充

CGContextStrokePath(ctx); //描出路径
CGContextFillPath(ctx) 使用非零绕数规则填充当前路径
CGContextDrawPath 两个参数决定填充规则,kCGPathFill表示用非零绕数规则,kCGPathEOFill表示用奇偶规则,kCGPathFillStroke表示填充,kCGPathEOFillStroke表示描线,不是填充
CGContextEOFillPath 使用奇偶规则填充当前路径
CGContextFillRect 填充指定的矩形
CGContextFillRects 填充指定的一些矩形
CGContextFillEllipseInRect 填充指定矩形中的椭圆

参考

ios绘图基础
http://liuyanwei.jumppo.com/2015/07/25/ios-draw-base.html

ios绘图demo,做一个涂鸦板(上)
http://liuyanwei.jumppo.com/2015/07/26/ios-draw-Graffiti.html

ios绘图demo,做一个涂鸦板(下)
http://liuyanwei.jumppo.com/2015/09/02/ios-draw-Graffiti-2.html

IOS绘制圆,直线,弧线,矩形,扇形,三角形,贝塞尔等图形:
http://blog.csdn.net/chocolateloveme/article/details/17246887

IOS开发UI篇—Quartz2D使用(绘图路径)
http://www.cnblogs.com/wendingding/p/3782679.html

Paths
http://donbe.blog.163.com/blog/static/138048021201052093633776/

IOS 使用Quartz 2D画虚线
http://blog.csdn.net/zhangao0086/article/details/7234859

  • 本文作者: Linking
  • 本文链接: https://linking.fun/2017/06/01/iOS绘图的副本/
  • 版权声明: 版权所有,转载请注明出处!
  • 绘图
  • iOS

扫一扫,分享到微信

iOS开发的系统兼容性问题解决
iOS多线程技术
  1. 1. Path:路径
  2. 2. Arcs:弧线
  3. 3. 画椭圆,矩形
  4. 4. Path:路径
  5. 5. 参考
© 2015-2026 Linking
GitHub:hexo-theme-yilia-plus by Litten
本站总访问量次 | 本站访客数人
  • 所有文章
  • 外链

tag:

  • weather
  • 需求
  • essay
  • basketball
  • olympic
  • nginx
  • APPScan
  • SQl盲注
  • xss
  • Ajax
  • ajax
  • ai
  • agent
  • openclaw
  • ccf
  • Nginx
  • HTML5
  • html5
  • hmtl5
  • sse
  • JavaScriptCore
  • Oracle
  • operation
  • Linux
  • deploy
  • Mac Office
  • markdown
  • ListView
  • GridView
  • MySQL
  • 慢查询
  • mongodb
  • 转置
  • thought
  • network
  • ubuntu
  • NetworkManager
  • RFKill
  • Netplan
  • avatar
  • cocoa
  • blog
  • Gitalk
  • container
  • macvlan
  • docker
  • oracle
  • cookie
  • patch
  • gitea
  • git
  • iOS
  • https
  • 多线程
  • bundle
  • 兼容性
  • HTTP
  • 绘图
  • cs
  • java
  • 效率
  • 快捷键
  • route
  • nodejs
  • pip
  • arcgis
  • arcgis 建模
  • 标识
  • redis
  • read
  • bookList
  • running
  • showdoc
  • disk
  • unit-test
  • D.Wade
  • thoughts
  • duoduo
  • Python
  • python
  • tomcat
  • 读书节
  • session
  • jdk
  • war
  • 加班
  • Android onclick事件监听
  • 正则
  • 手机品牌匹配
  • ntp
  • OpenLayers
  • Geoserver
  • wechat
  • 微信公众号
  • 爬虫
  • WeChat
  • 张靓颖
  • 动漫
  • vpn
  • PPT
  • MarkDown
  • plan
  • 朱赟
  • 极客时间专栏
  • 极客邦
  • 模块化
  • MVC
  • excel
  • NBA
  • kobe
  • team
  • crawler
  • 进度条
  • ssl
  • book
  • anti-stealing-link
  • Agentic Engineering
  • Vibe Coding
  • Software 3.0
  • Andrej Karpathy
  • LLM
  • Programming

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia-plus根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

  • GitHub Trending
  • OpenAI ChatGPT
  • Gitee码云
  • 简书
  • CSDN