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];

  • 相关阅读:
    中介者模式
    观察者模式
    javascript深入理解js闭包
    外观模式
    模板方法模式
    浅析C#深拷贝与浅拷贝
    C#浅拷贝与深拷贝区别
    6个重要的.NET概念:栈,堆,值类型,引用类型,装箱,拆箱
    原型模式
    设计模式总结
  • 原文地址:https://www.cnblogs.com/bluceZ/p/4629485.html
Copyright © 2011-2022 走看看