> ## Documentation Index
> Fetch the complete documentation index at: https://dev.marginnote.com.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 为插件设置图标

# 图标要求

图标文件需要是 PNG 图片，尺寸建议采用 64×64 ，但也可以根据实际需求采用更大或更小的图标。

MN 绘制图标时读取图标正中心像素的饱和度：高于 0.30 时按图片自身的颜色绘制，否则将图标当作 alpha 蒙版，只保留形状轮廓，用界面颜色绘制成单色。

因此图标需要满足以下条件：

* 图形以外的区域全部透明。
* 图标需要保留自身的色彩时，中心区域需要有一块不透明的高饱和色块。
* 图标在按钮上显示的尺寸较小，图形应当尽量扁平，避免使用渐变与阴影。

# 配置描述文件

建议在 `mnaddon.json` 中用 `icon` 字段指定图标文件：

```json mnaddon.json highlight={8} focus={8} theme={null}
{
  "addonid": "mn.hello",
  "title": "你好世界",
  "version": "0.1.0",
  "author": "我",
  "marginnote_version_min": "4.5.0",
  "panel": "index.html",
  "icon": "hello.png",
  "events": ["excerpt", "comments"]
}
```

MN 将按如下顺序采用图标

1. 采用 `icon` 字段中配置的图标。
2. `icon`字段未配置或无效时，采用与 `addonid` 末段同名的 PNG图标。 例如，`addonid` 为 `mn.hello` 时，采用 `hello.png`。
3. 仍未找到时，使用插件包内唯一的 PNG图标。

如果上述流程均失败，插件将无图标。

<Note>
  `icon`字段需相对插件包的根目录书写。路径中出现 `..` 或者使用绝对路径时，MN 会拒绝导入这个插件包。
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.