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 { ButtonGroup, IconButton, Tooltip } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { selectLassoMode, settingsLassoModeChanged } from 'features/controlLayers/store/canvasSettingsSlice';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { PiPolygonBold, PiScribbleLoopBold } from 'react-icons/pi';
import { TOOL_OPTION_ICON_SIZE } from './toolOptionIconSize';
export const ToolLassoModeToggle = memo(() => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const lassoMode = useAppSelector(selectLassoMode);
const setFreehand = useCallback(() => {
dispatch(settingsLassoModeChanged('freehand'));
}, [dispatch]);
const setPolygon = useCallback(() => {
dispatch(settingsLassoModeChanged('polygon'));
}, [dispatch]);
return (
<ButtonGroup isAttached size="sm">
<Tooltip label={t('controlLayers.lasso.freehand', { defaultValue: 'Freehand' })}>
<IconButton
aria-label={t('controlLayers.lasso.freehand', { defaultValue: 'Freehand' })}
icon={<PiScribbleLoopBold size={TOOL_OPTION_ICON_SIZE} />}
colorScheme={lassoMode === 'freehand' ? 'invokeBlue' : 'base'}
variant="solid"
onClick={setFreehand}
/>
</Tooltip>
<Tooltip label={t('controlLayers.lasso.polygon', { defaultValue: 'Polygon' })}>
<IconButton
aria-label={t('controlLayers.lasso.polygonHint', {
defaultValue: 'Click to add points, click the first point to close.',
})}
icon={<PiPolygonBold size={TOOL_OPTION_ICON_SIZE} />}
colorScheme={lassoMode === 'polygon' ? 'invokeBlue' : 'base'}
variant="solid"
onClick={setPolygon}
/>
</Tooltip>
</ButtonGroup>
);
});
ToolLassoModeToggle.displayName = 'ToolLassoModeToggle';