Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(canvas): match legacy denoising wave track

joshistoast3fb8248a7ad3
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.test.ts b/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.test.ts
index 5b96aa53ae..01c4a90486 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.test.ts
@@ -1,22 +1,32 @@
+import { createElement } from 'react';
+import { renderToStaticMarkup } from 'react-dom/server';
import { describe, expect, it } from 'vitest';
-import { getDenoisingStrengthWavePath } from './DenoisingStrengthWave';
+import { DenoisingStrengthWave, getDenoisingStrengthWavePath } from './DenoisingStrengthWave';
describe('getDenoisingStrengthWavePath', () => {
it('renders zero strength as a straight centered line', () => {
- expect(getDenoisingStrengthWavePath(0, 100, 12, 10)).toBe('M0,6 L100,6');
+ expect(getDenoisingStrengthWavePath(0, 100, 14, 5)).toBe('M0,7 L100,7');
});
it('increases wave amplitude with denoising strength', () => {
- const low = getDenoisingStrengthWavePath(0.25, 100, 12, 10);
- const high = getDenoisingStrengthWavePath(1, 100, 12, 10);
+ const low = getDenoisingStrengthWavePath(0.25, 100, 14, 5);
+ const high = getDenoisingStrengthWavePath(1, 100, 14, 5);
- expect(low).toContain('Q5,4.75 10,6');
- expect(high).toContain('Q5,1 10,6');
+ expect(low).toContain('Q10,4.5 20,7');
+ expect(high).toContain('Q10,0 20,7');
});
it('clamps strength before calculating amplitude', () => {
- expect(getDenoisingStrengthWavePath(-1, 100, 12, 10)).toBe(getDenoisingStrengthWavePath(0, 100, 12, 10));
- expect(getDenoisingStrengthWavePath(2, 100, 12, 10)).toBe(getDenoisingStrengthWavePath(1, 100, 12, 10));
+ expect(getDenoisingStrengthWavePath(-1, 100, 14, 5)).toBe(getDenoisingStrengthWavePath(0, 100, 14, 5));
+ expect(getDenoisingStrengthWavePath(2, 100, 14, 5)).toBe(getDenoisingStrengthWavePath(1, 100, 14, 5));
+ });
+
+ it('renders one continuous five-segment stroke without value-based dashes', () => {
+ const markup = renderToStaticMarkup(createElement(DenoisingStrengthWave, { value: 0.52 }));
+
+ expect(markup.match(/<path/g)).toHaveLength(1);
+ expect(markup).not.toContain('stroke-dasharray');
+ expect(markup.match(/ Q/g)).toHaveLength(5);
});
});
diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.tsx
index df17cb92cf..abd588e0cf 100644
--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.tsx
+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/DenoisingStrengthWave.tsx
@@ -1,4 +1,5 @@
const clamp01 = (value: number): number => Math.min(1, Math.max(0, value));
+const LEGACY_WAVE_AMPLITUDE_SCALE = 10;
export const getDenoisingStrengthWavePath = (
strength: number,
@@ -7,7 +8,7 @@ export const getDenoisingStrengthWavePath = (
segments: number
): string => {
const centerY = height / 2;
- const amplitude = clamp01(strength) * Math.max(0, centerY - 1);
+ const amplitude = Math.min(centerY, clamp01(strength) * LEGACY_WAVE_AMPLITUDE_SCALE);
if (amplitude === 0) {
return `M0,${centerY} L${width},${centerY}`;
}
@@ -24,13 +25,12 @@ export const getDenoisingStrengthWavePath = (
};
const WAVE_WIDTH = 100;
-const WAVE_HEIGHT = 12;
-const WAVE_SEGMENTS = 10;
+const WAVE_HEIGHT = 14;
+const WAVE_SEGMENTS = 5;
/** A value-reactive replacement for the denoising slider's straight track. */
export const DenoisingStrengthWave = ({ value }: { value: number }) => {
- const clampedValue = clamp01(value);
- const path = getDenoisingStrengthWavePath(clampedValue, WAVE_WIDTH, WAVE_HEIGHT, WAVE_SEGMENTS);
+ const path = getDenoisingStrengthWavePath(value, WAVE_WIDTH, WAVE_HEIGHT, WAVE_SEGMENTS);
return (
<svg
@@ -44,18 +44,8 @@ export const DenoisingStrengthWave = ({ value }: { value: number }) => {
<path
d={path}
fill="none"
- opacity="0.55"
- stroke="var(--chakra-colors-fg-muted)"
- strokeWidth="1.25"
- vectorEffect="non-scaling-stroke"
- />
- <path
- d={path}
- fill="none"
- pathLength={100}
stroke="var(--chakra-colors-accent-solid)"
- strokeDasharray={`${clampedValue * 100} 100`}
- strokeWidth="1.75"
+ strokeWidth="1.5"
vectorEffect="non-scaling-stroke"
/>
</svg>