mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 22:58:08 +00:00
BE change https://github.com/Comfy-Org/ComfyUI/pull/13322 ## Summary Add RANGE widget for image levels adjustment - Add RangeEditor widget with three display modes: plain, gradient, and histogram - Support optional midpoint (gamma) control for non-linear midtone adjustment - Integrate histogram display from upstream node outputs ## Screenshots (if applicable) <img width="1450" height="715" alt="image" src="https://github.com/user-attachments/assets/864976af-9eb7-4dd0-9ce1-2f5d7f003117" /> <img width="1431" height="701" alt="image" src="https://github.com/user-attachments/assets/7ee2af65-f87a-407b-8bf2-6ec59a1dff59" /> <img width="705" height="822" alt="image" src="https://github.com/user-attachments/assets/7bcb8f17-795f-498a-9f8a-076ed6c05a98" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10936-Range-editor-33b6d73d365081089e8be040b40f6c8a) by [Unito](https://www.unito.io)
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { histogramToPath } from './histogramUtil'
|
|
|
|
describe('histogramToPath', () => {
|
|
it('returns empty string for empty histogram', () => {
|
|
expect(histogramToPath(new Uint32Array(0))).toBe('')
|
|
})
|
|
|
|
it('returns empty string when all bins are zero', () => {
|
|
expect(histogramToPath(new Uint32Array(256))).toBe('')
|
|
})
|
|
|
|
it('returns a closed SVG path for valid histogram', () => {
|
|
const histogram = new Uint32Array(256)
|
|
for (let i = 0; i < 256; i++) histogram[i] = i + 1
|
|
const path = histogramToPath(histogram)
|
|
expect(path).toMatch(/^M0,1/)
|
|
expect(path).toMatch(/L1,1 Z$/)
|
|
})
|
|
|
|
it('normalizes using 99.5th percentile to suppress outliers', () => {
|
|
const histogram = new Uint32Array(256)
|
|
for (let i = 0; i < 256; i++) histogram[i] = 100
|
|
histogram[255] = 100000
|
|
const path = histogramToPath(histogram)
|
|
const yValues = path
|
|
.split(/[ML]/)
|
|
.filter(Boolean)
|
|
.map((s) => parseFloat(s.split(',')[1]))
|
|
.filter((y) => !isNaN(y))
|
|
const nearZero = yValues.filter((y) => Math.abs(y) < 0.01)
|
|
expect(nearZero.length).toBeGreaterThan(200)
|
|
})
|
|
})
|