接口: ColorPath
2022/10/22约 187 字小于 1 分钟
image.ColorPath
多色路径,用于多色查找。包含一个主颜色和多个偏移颜色。
目录
属性
属性
firstColor
• Readonly firstColor: Color
主颜色,即第一个要查找的颜色。
offsetColors
• offsetColors: OffsetColor[]
偏移颜色数组。每个偏移颜色相对于主颜色的位置和颜色值。
示例
"nodejs";
const { findMultiColors } = require("image");
const { Color } = require("color");
const colorPath = {
firstColor: new Color("#FF0000"), // 主颜色:红色
offsetColors: [
{ color: new Color("#00FF00"), offsetX: 10, offsetY: 0 }, // 主颜色右侧 10 像素处应该是绿色
{ color: new Color("#0000FF"), offsetX: 0, offsetY: 10 }, // 主颜色下方 10 像素处应该是蓝色
],
};
// 在图片中查找这个多色路径
const result = await findMultiColors(img, colorPath);