Skip to content
项目

关于

用于更好地将徽标在容器中居中对齐的工具。

设计与媒体

这些数字如何统计

实测星标增长

24小时
0
7天
+1
15天
+1
1个月
+1

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Visual Center

Tool that will find the visual center of your images / logos.

visual-center

How it works.

It calculates a visual weight value for every pixel on the image: the square root of the difference between that pixel and the background color. And then the algorithm tries to balance that weight in all directions.

Why the square root? http://spectrum.ieee.org/podcast/biomedical/bionics/does-the-brain-work-logarithmically

Programmatic Usage.

pnpm add visual-center
const getVisualCenter = require('visual-center')

getVisualCenter(<imgSrc>, function(err, result) {
  /*
    results in an object with the data as:
      {
        visualTop: <Visual center for Y axis, from 0 to 1>
        visualLeft: <Visual center for X axis, from 0 to 1>
        bgColor: <The background color that we detected>
        width: <The width of the image>
        height: <The height of the image>
      }
  */
})

License

BSD-3-Clause License

Made by Javier Bórquez. Online since 2016.

探索相关项目

加载中…