Colors

interface Colors : Variable

颜色处理工具接口,提供颜色获取、颜色比较及相似度计算等功能。

该接口封装了与颜色相关的核心操作,支持从图像或屏幕中提取颜色值, 并提供多种算法用于颜色相似度比较,适用于图像识别、颜色验证等场景。

所有颜色参数支持多种格式输入,包括RGB和ARGB类型,具体格式说明参见各方法注释。

Author

M8Test, contact@m8test.com, https://m8test.com

Functions

Link copied to clipboard
abstract fun getColorHex(image: String, x: Int, y: Int): String

获取图像中指定坐标的颜色十六进制值。

Link copied to clipboard
abstract fun getColorHexInDisplay(displayId: Int, x: Int, y: Int): String

获取屏幕中指定坐标的颜色十六进制值(自动申请权限)。

Link copied to clipboard
abstract fun getGlobalName(): String
Link copied to clipboard
abstract fun getPublicType(): Type
Link copied to clipboard
abstract fun getSimilarity(color1: String, color2: String, algorithm: String?, ignoreAlpha: Boolean?): Int

计算两个颜色的相似度得分。

Link copied to clipboard
abstract fun isPrefixRequired(): Boolean
Link copied to clipboard
abstract fun isSimilar(color1: String, color2: String, similarity: Int?, algorithm: String?, ignoreAlpha: Boolean?): Boolean

判断两个颜色是否达到指定相似度。

Link copied to clipboard
abstract fun isSuffixRequired(): Boolean