当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Context2d.quadraticCurveTo方法代码示例

本文整理汇总了TypeScript中core/util/canvas.Context2d.quadraticCurveTo方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Context2d.quadraticCurveTo方法的具体用法?TypeScript Context2d.quadraticCurveTo怎么用?TypeScript Context2d.quadraticCurveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core/util/canvas.Context2d的用法示例。


在下文中一共展示了Context2d.quadraticCurveTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: _render_seq

  _render_seq(ctx: Context2d, seq: (Draw | number)[]): void {
    let c: Draw = "M"
    let p = [0, 0]
    let i = 0

    while (i < seq.length) {
      if (isString(seq[i])) {
        c = seq[i] as Draw
        i += 1
      }

      switch (c) {
        case "M": {
          const [x, y] = seq.slice(i, i+2) as number[]
          ctx.moveTo(x, y)
          p = [x, y]
          i += 2
          break
        }
        case "L": {
          const [x, y] = seq.slice(i, i+2) as number[]
          ctx.lineTo(x, y)
          p = [x, y]
          i += 2
          break
        }
        case "C": {
          const [cx0, cy0, cx1, cy1, x, y] = seq.slice(i, i+6) as number[]
          ctx.bezierCurveTo(cx0, cy0, cx1, cy1, x, y)
          p = [x, y]
          i += 6
          break
        }
        case "Q": {
          const [cx0, cy0, x, y] = seq.slice(i, i+4) as number[]
          ctx.quadraticCurveTo(cx0, cy0, x, y)
          p = [x, y]
          i += 4
          break
        }
        case "A": {
          const [rx, ry, x_rotation, large_arc, sweep, x, y] = seq.slice(i, i+7) as number[]

          const [px, py] = p
          const segments = arc_to_bezier(px, py, rx, ry, -x_rotation, large_arc, 1 - sweep, x, y)

          for (const [cx0, cy0, cx1, cy1, x, y] of segments)
            ctx.bezierCurveTo(cx0, cy0, cx1, cy1, x, y)

          p = [x, y]
          i += 7
          break
        }
        default:
          throw new Error(`unexpected command: ${c}`)
      }
    }
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:58,代码来源:gear.ts

示例2: _render

  protected _render(ctx: Context2d, indices: number[], {sx0, sy0, sx1, sy1, scx, scy}: QuadraticData): void {
    if (this.visuals.line.doit) {
      for (const i of indices) {
        if (isNaN(sx0[i] + sy0[i] + sx1[i] + sy1[i] + scx[i] + scy[i]))
          continue

        ctx.beginPath()
        ctx.moveTo(sx0[i], sy0[i])
        ctx.quadraticCurveTo(scx[i], scy[i], sx1[i], sy1[i])

        this.visuals.line.set_vectorize(ctx, i)
        ctx.stroke()
      }
    }
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:15,代码来源:quadratic.ts

示例3: _render

  _render(ctx: Context2d, indices, {sx0, sy0, sx1, sy1, scx, scy}) {
    if (this.visuals.line.doit) {
      for (const i of indices) {
        if (isNaN(sx0[i]+sy0[i]+sx1[i]+sy1[i]+scx[i]+scy[i])) {
          continue;
        }

        ctx.beginPath();
        ctx.moveTo(sx0[i], sy0[i]);
        ctx.quadraticCurveTo(scx[i], scy[i], sx1[i], sy1[i]);

        this.visuals.line.set_vectorize(ctx, i);
        ctx.stroke();
      }
    }
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:16,代码来源:quadratic.ts


注:本文中的core/util/canvas.Context2d.quadraticCurveTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。