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

TypeScript arrayable.max函数代码示例

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

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



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

示例1: _hit_point

  protected _hit_point(geometry: PointGeometry): Selection {
    let {sx, sy} = geometry

    const x = this.renderer.xscale.invert(sx)
    const y = this.renderer.yscale.invert(sy)

    const scenter_x = []
    for (let i = 0, end = this.sx0.length; i < end; i++) {
      scenter_x.push(this.sx0[i] + this.sw[i]/2)
    }

    const scenter_y = []
    for (let i = 0, end = this.sy1.length; i < end; i++) {
      scenter_y.push(this.sy1[i] + this.sh[i]/2)
    }

    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: boolean, width_in: boolean
      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_empty_hit_test_result()
    result.indices = hits
    return result
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:51,代码来源:rect.ts


示例2: min

  protected _v_compute<T>(data: Arrayable<number>, values: Arrayable<T>,
      palette: Arrayable<T>, colors: {nan_color: T, low_color?: T, high_color?: T}): void {
    const {nan_color, low_color, high_color} = colors

    const n = palette.length
    const low = this.low != null ? this.low : min(data)
    const high = this.high != null ? this.high : max(data)
    const scale = n / (log1p(high) - log1p(low))  // subtract the low offset
    const max_key = palette.length - 1

    for (let i = 0, end = data.length; i < end; i++) {
      const d = data[i]

      // Check NaN
      if (isNaN(d)) {
        values[i] = nan_color
        continue
      }

      if (d > high) {
        values[i] = high_color != null ? high_color : palette[max_key]
        continue
      }

      // This handles the edge case where d == high, since the code below maps
      // values exactly equal to high to palette.length, which is greater than
      // max_key
      if (d == high) {
        values[i] = palette[max_key]
        continue
      }

      if (d < low) {
        values[i] = low_color != null ? low_color : palette[0]
        continue
      }

      // Get the key
      const log = log1p(d) - log1p(low)  // subtract the low offset
      let key = Math.floor(log * scale)

      // Deal with upper bound
      if (key > max_key)
        key = max_key

      values[i] = palette[key]
    }
  }
开发者ID:digitalsatori,项目名称:Bokeh,代码行数:48,代码来源:log_color_mapper.ts


示例3: min

  protected _v_compute<T>(data: Arrayable<number>, values: Arrayable<T>,
      palette: Arrayable<T>, colors: {nan_color: T, low_color?: T, high_color?: T}): void {
    const {nan_color, low_color, high_color} = colors

    const low = this.low != null ? this.low : min(data)
    const high = this.high != null ? this.high : max(data)
    const max_key = palette.length - 1

    const norm_factor = 1 / (high - low)
    const normed_interval = 1 / palette.length

    for (let i = 0, end = data.length; i < end; i++) {
      const d = data[i]

      if (isNaN(d)) {
        values[i] = nan_color
        continue
      }

      // This handles the edge case where d == high, since the code below maps
      // values exactly equal to high to palette.length, which is greater than
      // max_key
      if (d == high) {
        values[i] = palette[max_key]
        continue
      }

      const normed_d = (d - low) * norm_factor
      const key = Math.floor(normed_d / normed_interval)
      if (key < 0)
        values[i] = low_color != null ? low_color : palette[0]
      else if (key > max_key)
        values[i] = high_color != null ? high_color : palette[max_key]
      else
        values[i] = palette[key]
    }
  }
开发者ID:Zyell,项目名称:bokeh,代码行数:37,代码来源:linear_color_mapper.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript arrayable.sum函数代码示例发布时间:2022-05-24
下一篇:
TypeScript arrayable.map函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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