forked from noxious/client
npm run format
This commit is contained in:
@ -23,7 +23,10 @@ function analyzeTile(imageData: ImageData, tileId: string, tileName: string): Ti
|
||||
|
||||
function getDominantColorFast(imageData: ImageData) {
|
||||
const data = new Uint8ClampedArray(imageData.data.buffer)
|
||||
let r = 0, g = 0, b = 0, total = 0
|
||||
let r = 0,
|
||||
g = 0,
|
||||
b = 0,
|
||||
total = 0
|
||||
const length = data.length
|
||||
|
||||
for (let i = 0; i < length; i += 4 * PIXEL_SAMPLE_RATE) {
|
||||
@ -35,11 +38,13 @@ function getDominantColorFast(imageData: ImageData) {
|
||||
}
|
||||
}
|
||||
|
||||
return total > 0 ? {
|
||||
r: Math.round(r / total),
|
||||
g: Math.round(g / total),
|
||||
b: Math.round(b / total)
|
||||
} : { r: 0, g: 0, b: 0 }
|
||||
return total > 0
|
||||
? {
|
||||
r: Math.round(r / total),
|
||||
g: Math.round(g / total),
|
||||
b: Math.round(b / total)
|
||||
}
|
||||
: { r: 0, g: 0, b: 0 }
|
||||
}
|
||||
|
||||
function getEdgeComplexityFast(imageData: ImageData) {
|
||||
@ -51,14 +56,13 @@ function getEdgeComplexityFast(imageData: ImageData) {
|
||||
for (let y = 0; y < height; y += PIXEL_SAMPLE_RATE) {
|
||||
for (let x = 0; x < width; x += PIXEL_SAMPLE_RATE) {
|
||||
const i = (y * width + x) * 4
|
||||
if (data[i + 3] > 0 && (
|
||||
x === 0 || y === 0 || x >= width - PIXEL_SAMPLE_RATE || y >= height - PIXEL_SAMPLE_RATE ||
|
||||
data[i - 4 * PIXEL_SAMPLE_RATE + 3] === 0 || data[i + 4 * PIXEL_SAMPLE_RATE + 3] === 0 ||
|
||||
data[i - width * 4 * PIXEL_SAMPLE_RATE + 3] === 0 || data[i + width * 4 * PIXEL_SAMPLE_RATE + 3] === 0
|
||||
)) {
|
||||
if (
|
||||
data[i + 3] > 0 &&
|
||||
(x === 0 || y === 0 || x >= width - PIXEL_SAMPLE_RATE || y >= height - PIXEL_SAMPLE_RATE || data[i - 4 * PIXEL_SAMPLE_RATE + 3] === 0 || data[i + 4 * PIXEL_SAMPLE_RATE + 3] === 0 || data[i - width * 4 * PIXEL_SAMPLE_RATE + 3] === 0 || data[i + width * 4 * PIXEL_SAMPLE_RATE + 3] === 0)
|
||||
) {
|
||||
edgePixels++
|
||||
}
|
||||
}
|
||||
}
|
||||
return edgePixels * PIXEL_SAMPLE_RATE
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user