mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-10 18:26:45 +08:00
fix(glass): ease navbar optical sliders for default readability
This commit is contained in:
@@ -168,7 +168,7 @@ describe('GlassNavbarRefractionDefs', () => {
|
|||||||
effectiveSettings.value = { glassDeformationStrength: 48, glassTranslationStrength: 48 }
|
effectiveSettings.value = { glassDeformationStrength: 48, glassTranslationStrength: 48 }
|
||||||
await settle()
|
await settle()
|
||||||
expect(createGlassNavbarDisplacementMap).toHaveBeenLastCalledWith(
|
expect(createGlassNavbarDisplacementMap).toHaveBeenLastCalledWith(
|
||||||
expect.objectContaining({ optics: expect.objectContaining({ translationPx: 8.16 }) }),
|
expect.objectContaining({ optics: expect.objectContaining({ translationPx: expect.closeTo(1.880064) }) }),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -6,20 +6,28 @@ import {
|
|||||||
} from '@/utils/glassNavbarRefraction'
|
} from '@/utils/glassNavbarRefraction'
|
||||||
|
|
||||||
describe('getGlassNavbarOpticalResponse', () => {
|
describe('getGlassNavbarOpticalResponse', () => {
|
||||||
it('keeps default vertical deformation small while retaining substantial translation', () => {
|
it('prioritizes default reading while retaining the horizontal lens', () => {
|
||||||
const optics = getGlassNavbarOpticalResponse({ deformation: 48, translation: 48 })
|
const optics = getGlassNavbarOpticalResponse({ deformation: 48, translation: 48 })
|
||||||
expect(optics.translationPx).toBeCloseTo(8.16)
|
expect(optics.translationPx).toBeCloseTo(1.880064)
|
||||||
expect(optics.verticalRatio * 24).toBeLessThan(0.4)
|
expect(optics.verticalRatio * 24).toBeLessThan(0.02)
|
||||||
expect(optics.horizontalRatio * 24).toBeGreaterThan(3)
|
expect(optics.horizontalRatio * 24).toBeGreaterThan(2.9)
|
||||||
})
|
})
|
||||||
it.each([
|
it.each([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[50, 8.5],
|
[50, 2.125],
|
||||||
[99, 16.83],
|
[80, 8.704],
|
||||||
|
[99, 16.495083],
|
||||||
[100, 17],
|
[100, 17],
|
||||||
])('maps translation %s linearly to %s pixels', (translation, pixels) => {
|
])('maps translation %s to the readable curve at %s pixels', (translation, pixels) => {
|
||||||
expect(getGlassNavbarOpticalResponse({ deformation: 48, translation }).translationPx).toBeCloseTo(pixels)
|
expect(getGlassNavbarOpticalResponse({ deformation: 48, translation }).translationPx).toBeCloseTo(pixels)
|
||||||
})
|
})
|
||||||
|
it('keeps the midpoint deformation equivalent to the original 12.5% input', () => {
|
||||||
|
const parameters = Object.freeze({ deformation: 50, translation: 50 })
|
||||||
|
const optics = getGlassNavbarOpticalResponse(parameters)
|
||||||
|
expect(optics.horizontalRatio).toBeCloseTo(0.1386328125)
|
||||||
|
expect(optics.verticalRatio).toBeCloseTo(0.000859375)
|
||||||
|
expect(parameters).toEqual({ deformation: 50, translation: 50 })
|
||||||
|
})
|
||||||
it('separates translation from deformation and limits the maximum translation', () => {
|
it('separates translation from deformation and limits the maximum translation', () => {
|
||||||
expect(getGlassNavbarOpticalResponse({ deformation: 0, translation: 100 })).toEqual({
|
expect(getGlassNavbarOpticalResponse({ deformation: 0, translation: 100 })).toEqual({
|
||||||
horizontalRatio: 0,
|
horizontalRatio: 0,
|
||||||
|
|||||||
@@ -36,16 +36,16 @@ export interface GlassNavbarOpticalResponse {
|
|||||||
translationPx: number
|
translationPx: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 自然默认值即呈现明显短边折射;纵向形变与平移独立限幅以保护阅读。 */
|
/** 导航以低中段可读性为优先,高段保留完整位移预算;不改写共享参数或材质响应。 */
|
||||||
export function getGlassNavbarOpticalResponse(
|
export function getGlassNavbarOpticalResponse(
|
||||||
parameters: Pick<GlassOpticalParameters, 'deformation' | 'translation'>,
|
parameters: Pick<GlassOpticalParameters, 'deformation' | 'translation'>,
|
||||||
): GlassNavbarOpticalResponse {
|
): GlassNavbarOpticalResponse {
|
||||||
const deformation = normalizeGlassOpticalStrength(parameters.deformation) / 100
|
// 两个滑杆分别映射,50% 均使用 12.5% 的光学输入,避免平移维持高强度而抵消阅读改善。
|
||||||
const translation = normalizeGlassOpticalStrength(parameters.translation) / 100
|
const deformation = (normalizeGlassOpticalStrength(parameters.deformation) / 100) ** 3
|
||||||
|
const translation = (normalizeGlassOpticalStrength(parameters.translation) / 100) ** 3
|
||||||
return {
|
return {
|
||||||
horizontalRatio: 0.42 * (1 - (1 - deformation) ** 3),
|
horizontalRatio: 0.42 * (1 - (1 - deformation) ** 3),
|
||||||
verticalRatio: 0.055 * deformation ** 2,
|
verticalRatio: 0.055 * deformation ** 2,
|
||||||
// 平移使用线性刻度,50% 对应 8.5px;不把平移强度叠加到字形纵向缩放。
|
|
||||||
translationPx: 17 * translation,
|
translationPx: 17 * translation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user