Opengist

Explore

  • All gists
  • Topics
  • Users
Give feedback on the new UI Powered by Opengist ⋅ 9ms

user:thomas gists created by user

title:mygist gists with given title

description:sync gists with given description

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

all:systemctl search all fields

Login Register
y

yaml

Recently created Least recently created Recently updated Least recently updated
LixdHappy

LixdHappy / 取色API修复

Last active 4 months ago js yaml 主题 颜色

调用浏览器原生 Canvas API 在前端直接提取封面图主色调

1 0 2
1 // Canvas 前端取色
2 const getColorByCanvas = (img) => {
3 return new Promise((resolve, reject) => {
4 try {
5 img.crossOrigin = "Anonymous";
6 const extract = () => {
7 try {
8 const canvas = document.createElement("canvas");
9 const ctx = canvas.getContext("2d");
10 canvas.width = 1; canvas.height = 1;