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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
import { CompositeNumberInput, CompositeSlider, FormControl, FormLabel } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';
import { bboxHeightChanged } from 'features/controlLayers/store/canvasSlice';
import { selectGridSize, selectHeight, selectOptimalDimension } from 'features/controlLayers/store/selectors';
import { useIsBboxSizeLocked } from 'features/parameters/components/Bbox/use-is-bbox-size-locked';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
const CONSTRAINTS = {
initial: 512,
sliderMin: 64,
sliderMax: 2048,
numberInputMin: 64,
numberInputMax: 4096,
fineStep: 8,
coarseStep: 64,
};
export const BboxHeight = memo(() => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const optimalDimension = useAppSelector(selectOptimalDimension);
const height = useAppSelector(selectHeight);
const isBboxSizeLocked = useIsBboxSizeLocked();
const gridSize = useAppSelector(selectGridSize);
const onChange = useCallback(
(v: number) => {
dispatch(bboxHeightChanged({ height: v }));
},
[dispatch]
);
const marks = useMemo(() => [CONSTRAINTS.sliderMin, optimalDimension, CONSTRAINTS.sliderMax], [optimalDimension]);
return (
<FormControl isDisabled={isBboxSizeLocked}>
<InformationalPopover feature="paramHeight">
<FormLabel>{t('parameters.height')}</FormLabel>
</InformationalPopover>
<CompositeSlider
value={height}
defaultValue={optimalDimension}
onChange={onChange}
min={CONSTRAINTS.sliderMin}
max={CONSTRAINTS.sliderMax}
step={CONSTRAINTS.coarseStep}
fineStep={gridSize}
marks={marks}
/>
<CompositeNumberInput
value={height}
defaultValue={optimalDimension}
onChange={onChange}
min={CONSTRAINTS.numberInputMin}
max={CONSTRAINTS.numberInputMax}
step={CONSTRAINTS.coarseStep}
fineStep={gridSize}
/>
</FormControl>
);
});
BboxHeight.displayName = 'BboxHeight';