zoukankan      html  css  js  c++  java
  • 贝赛尔曲线

    /**

     绘图步骤

     1. 获得上下文          Ref => UIGraphicsGetCurrentContext

     2. 设置绘图路径(贝塞尔路径是UIKit封装的) UIBezierPath

     3. 将路径添加到上下文   CGContextAddPath(ctx, path.CGPath);

     4. 让上下文绘制路径     CGContextDrawPath(ctx, kCGPathStroke);

     */

    //获得图形上下文

    CGContextRef ctx = UIGraphicsGetCurrentContext();

     设置绘图路径(贝塞尔路径是UIKit封装的)

    //画圆

    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(40, 60, 40, 40)];

    //画矩形

    UIBezierPath *path1 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(80, 180, 120, 60) cornerRadius:10.0];

    //画线

       // 2. 贝塞尔路径

        UIBezierPath *path = [UIBezierPath bezierPath];

        // 2.1 设置起点

        [path moveToPoint:CGPointMake(10, 10)];

        // 2.2 画线

        [path addLineToPoint:CGPointMake(140, 120)];

        [path addLineToPoint:CGPointMake(270, 10)];

        // 关闭路径,从最后一个点,连接到起点,产生一条封闭的路径

        [path closePath];

  • 相关阅读:
    javaweb 最简单的分页技术
    Jquery选择器小结
    JSON 初探
    C# GridView 的使用
    C# 操作数据库
    Java中String为什么是不可变
    Eclipse使用技巧小结
    Java File类方法使用详解
    JSP基础语法总结
    JSP取得绝对路径
  • 原文地址:https://www.cnblogs.com/bluceZ/p/4629485.html
Copyright © 2011-2022 走看看