直接看示範頁面就可以理解了:「jquery.adaptive-backgrounds.js • A jQuery plugin for extracting dominant colors from images and applying it to its parent」。
GitHub 的頁面在「briangonzalez/jquery.adaptive-backgrounds.js」。
如果圖片不在同一個 domain 下,會需要設定 CORS 權限 (Cross Origin Resource Sharing),或是在 img
tag 下指定 crossorigin
屬性讓程式可以讀取。