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


TypeScript canvas.Context2d类代码示例

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


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

示例1: _paint_levels

  _paint_levels(ctx: Context2d, levels, clip_region = null) {
    ctx.save();

    if ((clip_region != null) && (this.model.plot.output_backend === "canvas")) {
      ctx.beginPath();
      ctx.rect.apply(ctx, clip_region);
      ctx.clip();
    }

    const indices = {};
    for (let i = 0; i < this.model.plot.renderers.length; i++) {
      const renderer = this.model.plot.renderers[i];
      indices[renderer.id] = i;
    }

    const sortKey = renderer_view => indices[renderer_view.model.id];

    for (const level of levels) {
      const renderer_views = sortBy(values(this.levels[level]), sortKey);

      for (const renderer_view of renderer_views) {
        renderer_view.render();
      }
    }

    return ctx.restore();
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:27,代码来源:plot_canvas.ts

示例2: _paint_levels

  protected _paint_levels(ctx: Context2d, levels: string[], clip_region?: FrameBox): void {
    ctx.save()

    if (clip_region != null) {
      ctx.beginPath()
      ctx.rect.apply(ctx, clip_region)
      ctx.clip()
    }

    const indices: {[key: string]: number} = {}
    for (let i = 0; i < this.model.plot.renderers.length; i++) {
      const renderer = this.model.plot.renderers[i]
      indices[renderer.id] = i
    }

    const sortKey = (renderer_view: RendererView) => indices[renderer_view.model.id]

    for (const level of levels) {
      const renderer_views = sortBy(values(this.levels[level]), sortKey)

      for (const renderer_view of renderer_views) {
        renderer_view.render()
      }
    }

    ctx.restore()
  }
开发者ID:gully,项目名称:bokeh,代码行数:27,代码来源:plot_canvas.ts

示例3: _one_diamond

function _one_diamond(ctx: Context2d, r: number): void {
  ctx.moveTo(0, r)
  ctx.lineTo(r/1.5, 0)
  ctx.lineTo(0, -r)
  ctx.lineTo(-r/1.5, 0)
  ctx.closePath()
}
开发者ID:Zyell,项目名称:bokeh,代码行数:7,代码来源:index.ts

示例4: function

const _one_diamond = function(ctx: Context2d, r) {
  ctx.moveTo(0, r);
  ctx.lineTo(r/1.5, 0);
  ctx.lineTo(0, -r);
  ctx.lineTo(-r/1.5, 0);
  return ctx.closePath();
};
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:7,代码来源:index.ts

示例5: _render

  protected _render(ctx: Context2d, indices: number[], {sxs, sys}: MultiPolygonsData): void {
    if (this.visuals.fill.doit || this.visuals.line.doit) {

      for (const i of indices) {
        const [sx, sy] = [sxs[i], sys[i]]

        if (this.visuals.fill.doit) {
          this.visuals.fill.set_vectorize(ctx, i)
          this._inner_loop(ctx, sx, sy)
          ctx.fill("evenodd")
        }

        this.visuals.hatch.doit2(ctx, i, () => {
          this._inner_loop(ctx, sx, sy)
          ctx.fill("evenodd")
        }, () => this.renderer.request_render())

        if (this.visuals.line.doit) {
          this.visuals.line.set_vectorize(ctx, i)
          this._inner_loop(ctx, sx, sy)
          ctx.stroke()
        }
      }
    }
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:25,代码来源:multi_polygons.ts

示例6: _draw_major_labels

  _draw_major_labels(ctx: Context2d, tick_info) {
    if (!this.visuals.major_label_text.doit) {
      return;
    }

    const [nx, ny] = this.model._normals();
    const image = this.model._computed_image_dimensions();
    const [x_offset, y_offset] = [image.width * nx, image.height * ny];
    const standoff = (this.model.label_standoff + this.model._tick_extent());
    const [x_standoff, y_standoff] = [standoff*nx, standoff*ny];

    const [sx, sy] = tick_info.coords.major;

    const formatted_labels = tick_info.labels.major;

    this.visuals.major_label_text.set_value(ctx);

    ctx.save();
    ctx.translate(x_offset + x_standoff, y_offset + y_standoff);
    for (let i = 0, end = sx.length; i < end; i++) {
      ctx.fillText(formatted_labels[i],
                   Math.round(sx[i]+(nx*this.model.label_standoff)),
                   Math.round(sy[i]+(ny*this.model.label_standoff)));
    }
    return ctx.restore();
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:26,代码来源:color_bar.ts

示例7: _render

  _render(ctx: Context2d, indices, {image_data, sx, sy, sw, sh}) {
    const old_smoothing = ctx.getImageSmoothingEnabled();
    ctx.setImageSmoothingEnabled(false);

    for (const i of indices) {
      if ((image_data[i] == null)) {
        continue;
      }
      if (isNaN(sx[i]+sy[i]+sw[i]+sh[i])) {
        continue;
      }

      const y_offset = sy[i];

      ctx.translate(0, y_offset);
      ctx.scale(1, -1);
      ctx.translate(0, -y_offset);
      ctx.drawImage(image_data[i], sx[i]|0, sy[i]|0, sw[i], sh[i]);
      ctx.translate(0, y_offset);
      ctx.scale(1, -1);
      ctx.translate(0, -y_offset);
    }

    return ctx.setImageSmoothingEnabled(old_smoothing);
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:25,代码来源:image.ts

示例8: _normal

 _normal(ctx: Context2d, _i: number): void {
   ctx.beginPath()
   ctx.moveTo(0.5*this.size, this.size)
   ctx.lineTo(0, 0)
   ctx.lineTo(-0.5*this.size, this.size)
   ctx.closePath()
 }
开发者ID:Zyell,项目名称:bokeh,代码行数:7,代码来源:arrow_head.ts

示例9: _draw_ticks

  protected _draw_ticks(ctx: Context2d, coords: Coords, tin: number, tout: number, visuals: Line): void {
    if (!visuals.doit)
      return

    const [x, y]       = coords
    const [sxs, sys]   = this.plot_view.map_to_screen(x, y, this.model.x_range_name, this.model.y_range_name)
    const [nx, ny]     = this.model.normals
    const [xoff, yoff] = this.model.offsets

    const [nxin,  nyin]  = [nx * (xoff-tin),  ny * (yoff-tin)]
    const [nxout, nyout] = [nx * (xoff+tout), ny * (yoff+tout)]

    visuals.set_value(ctx)

    for (let i = 0; i < sxs.length; i++) {
      const sx0 = Math.round(sxs[i] + nxout)
      const sy0 = Math.round(sys[i] + nyout)
      const sx1 = Math.round(sxs[i] + nxin)
      const sy1 = Math.round(sys[i] + nyin)
      ctx.beginPath()
      ctx.moveTo(sx0, sy0)
      ctx.lineTo(sx1, sy1)
      ctx.stroke()
    }
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:25,代码来源:axis.ts

示例10: _render

  protected _render(ctx: Context2d, indices: number[], {image_data, sx, sy, sw, sh}: _ImageData): void {
    const old_smoothing = ctx.getImageSmoothingEnabled()
    ctx.setImageSmoothingEnabled(false)

    ctx.globalAlpha = this.model.global_alpha

    for (const i of indices) {
      if (image_data[i] == null)
        continue

      if (isNaN(sx[i] + sy[i] + sw[i] + sh[i]))
        continue

      const y_offset = sy[i]

      ctx.translate(0, y_offset)
      ctx.scale(1, -1)
      ctx.translate(0, -y_offset)
      ctx.drawImage(image_data[i], sx[i]|0, sy[i]|0, sw[i], sh[i])
      ctx.translate(0, y_offset)
      ctx.scale(1, -1)
      ctx.translate(0, -y_offset)
    }

    ctx.setImageSmoothingEnabled(old_smoothing)
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:26,代码来源:image.ts


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