Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
V

visual-center

> 前端框架
Open source

Tool to better align logos in the center of a container.

1.4K stars0 likes2 views
WebsiteGitHub

About

Tool to better align logos in the center of a container.

Visual Center

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

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(, 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.

GitHub Issues· 4 open

View all on GitHub
  • #10

    Saving the centered image.

    Updated Mar 12, 2025
  • #13

    Is the Medium article available?

    Updated Sep 14, 2020
  • #1

    Sketch plugin would be dope ;)

    Updated May 18, 2016

Highlights

  • •JavaScript
  • •art
  • •design
  • •design-tool
  • •frontend

> Tags

JavaScriptartdesigndesign-toolfrontend

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架