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


TypeScript dom.canvas函数代码示例

本文整理汇总了TypeScript中core/dom.canvas函数的典型用法代码示例。如果您正苦于以下问题:TypeScript canvas函数的具体用法?TypeScript canvas怎么用?TypeScript canvas使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: initialize

  initialize(options: any): void {
    super.initialize(options)

    this.map_el = this.model.map ? this.el.appendChild(div({class: "bk-canvas-map"})) : null

    switch (this.model.output_backend) {
      case "canvas":
      case "webgl": {
        this.canvas_el = this.el.appendChild(canvas({class: "bk-canvas"}))
        const ctx = this.canvas_el.getContext('2d')
        if (ctx == null)
          throw new Error("unable to obtain 2D rendering context")
        this._ctx = ctx
        break
      }
      case "svg": {
        const ctx = new SVGRenderingContext2D()
        this._ctx = ctx
        this.canvas_el = this.el.appendChild(ctx.getSvg())
        break
      }
    }

    this.overlays_el = this.el.appendChild(div({class: "bk-canvas-overlays"}))
    this.events_el   = this.el.appendChild(div({class: "bk-canvas-events"}))

    fixup_ctx(this._ctx)

    logger.debug("CanvasView initialized")
  }
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: initialize

  initialize(options: any): void {
    super.initialize(options)

    this.map_el = this.model.map ? this.el.appendChild(div({class: "bk-canvas-map"})) : null

    switch (this.model.output_backend) {
      case "canvas":
      case "webgl":
        this.canvas_el = this.el.appendChild(canvas({class: "bk-canvas"}))
        this._ctx = this.canvas_el.getContext('2d')
        break
      case "svg":
        this._ctx = new canvas2svg()
        this.canvas_el = this.el.appendChild(this._ctx.getSvg())
        break
    }

    this.overlays_el = this.el.appendChild(div({class: "bk-canvas-overlays"}))
    this.events_el   = this.el.appendChild(div({class: "bk-canvas-events"}))

    this.ctx = this.get_ctx()
    // work around canvas incompatibilities
    fixup_ctx(this.ctx)

    logger.debug("CanvasView initialized")
  }
开发者ID:gully,项目名称:bokeh,代码行数:26,代码来源:canvas.ts

示例3: initialize

  initialize(): void {
    super.initialize()

    this.map_el = this.model.map ? this.el.appendChild(div({class: "bk-canvas-map"})) : null

    const style = {
      position: "absolute",
      top: "0",
      left: "0",
      width: "100%",
      height: "100%",
    }

    switch (this.model.output_backend) {
      case "canvas":
      case "webgl": {
        this.canvas_el = this.el.appendChild(canvas({class: "bk-canvas", style}))
        const ctx = this.canvas_el.getContext('2d')
        if (ctx == null)
          throw new Error("unable to obtain 2D rendering context")
        this._ctx = ctx
        break
      }
      case "svg": {
        const ctx = new canvas2svg() as SVGRenderingContext2D
        this._ctx = ctx
        this.canvas_el = this.el.appendChild(ctx.getSvg())
        break
      }
    }

    this.overlays_el = this.el.appendChild(div({class: "bk-canvas-overlays", style}))
    this.events_el   = this.el.appendChild(div({class: "bk-canvas-events", style}))

    fixup_ctx(this._ctx)

    logger.debug("CanvasView initialized")
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:38,代码来源:canvas.ts


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