# @emeraldpay/hashicon 中文文档

规范地址：https://npmcn.com/package/%40emeraldpay/hashicon/

版本：0\.5\.2
npm 元数据更新时间：2022-04-05T07:32:17.542Z
中文译文更新时间：2026-11-13T15:28:27.726Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40emeraldpay/hashicon
原文对照：https://npmcn.com/package/%40emeraldpay/hashicon/?lang=original
项目主页：https://etcdevteam.github.io/hashicon/examples/
源码仓库：https://github.com/emeraldpay/hashicon

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：35.9 kB，16 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=8
- 运行依赖：2 个
- 首次发布：2020-07-08T03:22:30.153Z
- 最新版本发布：2022-02-08T02:51:56.547Z
- 近 30 天下载量：5006（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

Hashicon - 作为六边形的散列值的视觉表现

## 安装

```sh
npm install @emeraldpay/hashicon
```

也可以使用：`pnpm add @emeraldpay/hashicon`、`yarn add @emeraldpay/hashicon`、`bun add @emeraldpay/hashicon`

## README

# 桥口

> 产生一个美丽的代表 任何大麻.

## 安装

安装方式 :

```shell
$ npm install @emeraldpay/hashicon --save
```

## 使用量

东西,你想代表视觉。 例如屏幕上对象的ID.

```js
// 
const value = "9dddff8f-be81-4c27-80c8-099327865f3f";
```

创建一个 `hashicon` 默认参数 :

```js
import { hashicon } from 'hashicon';

const icon = hashicon(value); // icon is a <canvas> element
const icon = hashicon(value, 80);  // size 80px
```

或者,通过习惯 [段落](https://npmcn.com/package/%40emeraldpay/hashicon/#readme-params)数字 :

```js
const params = {...};
const icon = hashicon(value, params);
```

最后,附上新创建的 `hashicon` 至 HTML 文档:

```js
document.body.appendChild(icon);
```

## 参数

> 见 [默认参数](https://npmcn.com/package/%40emeraldpay/hashicon/src/params.ts)

HashIcon的值从散列中取出,并用以下参数来控制来操纵可能的视觉输出: 1

```js
{

// hasher for the input value. "blake2" is default 
// can also be "keccak" (or "legacy"), at this case add dependency to "js-sha3" package
hasher: "blake2",

// size px (HiDPI/Retina aware)
size: 100,

// primary color range radius ( 0=red, 60=yellow, 120=green, ..., 360=red )
hue: { min: 0, max: 360 },

// saturation ( 0=grey, 100=colorfull )
saturation: { min: 70, max: 100 },

// lightness ( 0=extremlydark, 50=optimal, 100=extremlybright )
lightness: { min: 45, max: 65 },

// hue variation for individual triangles
variation: { min: 7, max: 14, enabled: true },

// color shift from primary hue to secondary hue ( the pattern )
shift: { min: 60, max: 300 },

// the pattern opacity
figurealpha: { min: .7, max: 1.2 }, // alpha

// simulate a 3d cube by different areas gets some more/less light applyed 
light:{ top:10, right:-8, left:-4, enabled: true},

// Allows a custom canvas to be used to render into
createCanvas: (width, height) => HTMLCanvasElement

}
```

## 常见问题

### @emeraldpay/hashicon 是什么？

Hashicon - 作为六边形的散列值的视觉表现

### 如何安装 @emeraldpay/hashicon？

在项目目录运行 npm install @emeraldpay/hashicon，或使用 pnpm add / yarn add / bun add。

### @emeraldpay/hashicon 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @emeraldpay/hashicon 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @emeraldpay/hashicon 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=8。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @emeraldpay/hashicon 可以商用吗？

@emeraldpay/hashicon 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @emeraldpay/hashicon 的下载量有多少？

根据 npm 官方下载统计，@emeraldpay/hashicon 在 2026/10/14 – 2026/11/12 这 30 天内被下载 5,006 次，日均约 167 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @emeraldpay/hashicon 还在维护吗？

最新版本 0\.5\.2 发布于 2022/02/08（4 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2020/07/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

