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 { Button } from '@invoke-ai/ui-library';
import { NUMPY_RAND_MAX, NUMPY_RAND_MIN } from 'app/constants';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import randomInt from 'common/util/randomInt';
import { selectShouldRandomizeSeed, setSeed } from 'features/controlLayers/store/paramsSlice';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiShuffleBold } from 'react-icons/pi';
export const ParamSeedShuffle = memo(() => {
const dispatch = useAppDispatch();
const shouldRandomizeSeed = useAppSelector(selectShouldRandomizeSeed);
const { t } = useTranslation();
const handleClickRandomizeSeed = useCallback(
() => dispatch(setSeed(randomInt(NUMPY_RAND_MIN, NUMPY_RAND_MAX))),
[dispatch]
);
return (
<Button
size="sm"
isDisabled={shouldRandomizeSeed}
onClick={handleClickRandomizeSeed}
leftIcon={<PiShuffleBold />}
flexShrink={0}
>
{t('parameters.shuffle')}
</Button>
);
});
ParamSeedShuffle.displayName = 'ParamSeedShuffle';