• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript hittest.create_hit_test_result函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _hit_point

  _hit_point(geometry) {
    /* Check if the point geometry hits this line glyph and return an object
    that describes the hit result:
      Args:
        * geometry (object): object with the following keys
          * sx (float): screen x coordinate of the point
          * sy (float): screen y coordinate of the point
          * type (str): type of geometry (in this case it's a point)
      Output:
        Object with the following keys:
          * 0d (bool): whether the point hits the glyph or not
          * 1d (array(int)): array with the indices hit by the point
    */
    const result = hittest.create_hit_test_result();
    const point = {x: geometry.sx, y: geometry.sy};
    let shortest = 9999;
    const threshold = Math.max(2, this.visuals.line.line_width.value() / 2);

    for (let i = 0, end = this.sx.length-1; i < end; i++) {
      const [p0, p1] = [{x: this.sx[i], y: this.sy[i]}, {x: this.sx[i+1], y: this.sy[i+1]}];
      const dist = hittest.dist_to_segment(point, p0, p1);

      if ((dist < threshold) && (dist < shortest)) {
        shortest = dist;
        result['0d'].glyph = this.model;
        result['0d'].get_view = () => this
        result['0d'].flag = true;  // backward compat
        result['0d'].indices = [i];
      }
    }

    return result;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:33,代码来源:line.ts


示例2: _hit_span

  _hit_span(geometry) {
    let v0, v1, val;
    const [hr, vr] = this.renderer.plot_view.frame.bbox.ranges;
    const {sx, sy} = geometry;

    if (geometry.direction === 'v') {
      val = this.renderer.yscale.invert(sy);
      [v0, v1] = [this._y0, this._y1];
    } else {
      val = this.renderer.xscale.invert(sx);
      [v0, v1] = [this._x0, this._x1];
    }

    const hits = [];

    const [minX, maxX] = this.renderer.xscale.r_invert(hr.start, hr.end);
    const [minY, maxY] = this.renderer.yscale.r_invert(vr.start, vr.end);
    const candidates = this.index.indices({minX, minY, maxX, maxY});

    for (const i of candidates) {
      if ((v0[i]<=val && val<=v1[i]) || (v1[i]<=val && val<=v0[i])) {
        hits.push(i);
      }
    }

    const result = hittest.create_hit_test_result();
    result['1d'].indices = hits;
    return result;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:29,代码来源:segment.ts


示例3: convert_selection_to_subset

 convert_selection_to_subset(selection_full): HitTestResult {
   const selection_subset = create_hit_test_result()
   selection_subset.update_through_union(selection_full)
   const indices_1d = (selection_full['1d']['indices'].map((i) => this.indices_map[i]))
   selection_subset['1d']['indices'] = indices_1d
   return selection_subset
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:7,代码来源:cds_view.ts


示例4: _do

  _do(geometry, graph_view, final, append) {
    const [node_view, edge_view] = [graph_view.node_view, graph_view.edge_view];
    const hit_test_result = node_view.glyph.hit_test(geometry);

    // glyphs that don't have hit-testing implemented will return null
    if (hit_test_result === null) {
      return false;
    }

    this._node_selector.update(hit_test_result, final, append);

    const node_indices = ((() => {
      const result = [];
      for (const i of hit_test_result["1d"].indices) {
        result.push(node_view.model.data_source.data.index[i]);
      }
      return result;
    })());
    const edge_source = edge_view.model.data_source;
    const edge_indices = [];
    for (let i = 0, end = edge_source.data.start.length; i < end; i++) {
      if (includes(node_indices, edge_source.data.start[i]) || includes(node_indices, edge_source.data.end[i])) {
        edge_indices.push(i);
      }
    }

    const linked_index = create_hit_test_result();
    for (const i of edge_indices) {
      linked_index["2d"].indices[i] = [0];
    } //currently only supports 2-element multilines, so this is all of it

    this._edge_selector.update(linked_index, final, append);

    return !this._node_selector.indices.is_empty();
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:35,代码来源:graph_hit_test_policy.ts


示例5: _hit_span

  _hit_span(geometry) {
    let ms, x0, x1, y0, y1;
    const {sx, sy} = geometry;
    const {minX, minY, maxX, maxY} = this.bounds();
    const result = hittest.create_hit_test_result();

    if (geometry.direction === 'h') {
      y0 = minY;
      y1 = maxY;
      ms = this.max_size/2;
      const sx0 = sx - ms;
      const sx1 = sx + ms;
      [x0, x1] = this.renderer.xscale.r_invert(sx0, sx1);
    } else {
      x0 = minX;
      x1 = maxX;
      ms = this.max_size/2;
      const sy0 = sy - ms;
      const sy1 = sy + ms;
      [y0, y1] = this.renderer.yscale.r_invert(sy0, sy1);
    }

    const bbox = hittest.validate_bbox_coords([x0, x1], [y0, y1]);
    const hits = this.index.indices(bbox);

    result['1d'].indices = hits;
    return result;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:28,代码来源:marker.ts


示例6:

      this.grid.onSelectedRowsChanged.subscribe((_event, args) => {
        if (this.in_selection_update) {
          return;
        }

        const selected = hittest.create_hit_test_result();
        selected['1d'].indices = (args.rows.map((i) => this.data.index[i]));
        return this.model.source.selected = selected;
      });
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:9,代码来源:data_table.ts


示例7: _hit_rect

 _hit_rect(geometry) {
   const {sx0, sx1, sy0, sy1} = geometry;
   const [x0, x1] = this.renderer.xscale.r_invert(sx0, sx1);
   const [y0, y1] = this.renderer.yscale.r_invert(sy0, sy1);
   const bbox = hittest.validate_bbox_coords([x0, x1], [y0, y1]);
   const result = hittest.create_hit_test_result();
   result['1d'].indices = this.index.indices(bbox);
   return result;
 }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:9,代码来源:marker.ts


示例8: _hit_point

  _hit_point(geometry) {
    let {sx, sy} = geometry;
    const x = this.renderer.xscale.invert(sx);
    const y = this.renderer.yscale.invert(sy);

    const scenter_x = ((() => {
      const result1 = [];
      for (let i = 0, end = this.sx0.length; i < end; i++) {
        result1.push(this.sx0[i] + (this.sw[i]/2));
      }
      return result1;
    })());
    const scenter_y = ((() => {
      const result2 = [];
      for (let i = 0, end = this.sy1.length; i < end; i++) {
        result2.push(this.sy1[i] + (this.sh[i]/2));
      }
      return result2;
    })());

    const max_x2_ddist = max(this._ddist(0, scenter_x, this.ssemi_diag));
    const max_y2_ddist = max(this._ddist(1, scenter_y, this.ssemi_diag));

    const x0 = x - max_x2_ddist;
    const x1 = x + max_x2_ddist;
    const y0 = y - max_y2_ddist;
    const y1 = y + max_y2_ddist;

    const hits = [];

    const bbox = hittest.validate_bbox_coords([x0, x1], [y0, y1]);
    for (const i of this.index.indices(bbox)) {
      let height_in, width_in;
      if (this._angle[i]) {
        const s = Math.sin(-this._angle[i]);
        const c = Math.cos(-this._angle[i]);
        const px = ((c * (sx-this.sx[i])) - (s * (sy-this.sy[i]))) + this.sx[i];
        const py = (s * (sx-this.sx[i])) + (c * (sy-this.sy[i])) + this.sy[i];
        sx = px;
        sy = py;
        width_in = Math.abs(this.sx[i]-sx) <= (this.sw[i]/2);
        height_in = Math.abs(this.sy[i]-sy) <= (this.sh[i]/2);
      } else {
        width_in = ((sx - this.sx0[i]) <= this.sw[i]) && ((sx - this.sx0[i]) >= 0);
        height_in = ((sy - this.sy1[i]) <= this.sh[i]) && ((sy - this.sy1[i]) >= 0);
      }

      if (height_in && width_in) {
        hits.push(i);
      }
    }

    const result = hittest.create_hit_test_result();
    result['1d'].indices = hits;
    return result;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:56,代码来源:rect.ts


示例9: _hit_point

  _hit_point(geometry) {
    const {sx, sy} = geometry;
    const x = this.renderer.xscale.invert(sx);
    const y = this.renderer.yscale.invert(sy);

    const hits = this.index.indices({minX: x, minY: y, maxX: x, maxY: y});

    const result = hittest.create_hit_test_result();
    result['1d'].indices = hits;
    return result;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:11,代码来源:box.ts


示例10: _hit_poly

  _hit_poly(geometry) {
    const {sx, sy} = geometry;

    // TODO (bev) use spatial index to pare candidate list
    const candidates = range(0, this.sx.length);

    const hits = [];
    for (let i = 0, end = candidates.length; i < end; i++) {
      const idx = candidates[i];
      if (hittest.point_in_poly(this.sx[i], this.sy[i], sx, sy)) {
        hits.push(idx);
      }
    }
    const result = hittest.create_hit_test_result();
    result['1d'].indices = hits;
    return result;
  }
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:17,代码来源:marker.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap