zoukankan      html  css  js  c++  java
  • ios 绘制线条

    //添加被塞尔曲线 
       CGContextMoveToPoint(cgContext, 150, 100); //移动到某一个点           
       CGContextAddCurveToPoint(cgContext, 150, 100, 100, 100, 100, 150);//绘制被塞尔曲线,点伴随移动,这三个参数呢,每2个为一个参数
        1.point(150100)表示开始点
        2.point(100100)表示为控制点
        3.point(100150)表示为终止点
       //综上:就是绘制一条曲线的切线相交处为控制点
        CGContextAddCurveToPoint(cgContext, 100, 150, 100, 200, 150, 200);//
        CGContextAddCurveToPoint(cgContext, 150, 200, 200, 200, 200, 150);//
        CGContextAddCurveToPoint(cgContext, 200, 150, 200, 100, 150, 100);//
        [[UIColor redColor] setFill];//填充颜色
        CGContextDrawPath(cgContext, kCGPathStroke);//画笔画上
       //  CGContextAddLineToPoint(cgContext, 50, 50);
    CGContextAddLineToPoint(cgContext, 200, 30);//添加一条直线
    //添加一个矩形
    CGContextAddRect(cgContext, CGRectMake(100, 100, 100, 100));
    //添加弧度
    CGContextAddArc(cgContext, 100, 100, 50,  3.14/ 2, 270* 3.14/ 180, 1);
    //1.原点(100,100)
    //2.半径 50
    //3.开始弧度 3.14/ 2 ,3.14就是圆周率
    //4.结束弧度270* 3.14/ 180
    //5.逆时针为1,0为顺时针
    //---------- 解释一下圆的弧度,弧度是按照顺时针来计算弧度的,那么开始弧度和结束弧度就确定了,弧度确定了那么按照顺逆时针来画就比较简单了
    CGContextClosePath(cgContext);//封闭曲线
    CGContextAddEllipseInRect(cgContext, CGRectMake(100, 100, 200, 100));//在一个矩形里面内切一个椭圆其实是比较简单的
  • 相关阅读:
    MySql 数据备份与还原
    PHP 连接数据库
    迭代法写线性回归
    ML numpy、pandas、matplotlib的使用
    005 动态加载实例
    爬虫实现案例
    004 使用scrapy框架爬虫
    003 爬虫持久化的三个不同数据库的python代码
    内置函数和匿名函数
    迭代器和生成器
  • 原文地址:https://www.cnblogs.com/liyang31tg/p/4114981.html
Copyright © 2011-2022 走看看