优化放大镜工具,增加高亮颜色支持,更新提示信息以提升用户交互体验和界面友好性。
This commit is contained in:
@@ -1903,14 +1903,14 @@ export default function Home() {
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-3.5 w-3.5 text-blue-500 dark:text-blue-400 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
|
||||
</svg>
|
||||
<span>使用右上角悬浮调色盘进行上色操作</span>
|
||||
<span>使用右上角菜单操作</span>
|
||||
</div>
|
||||
<span className="hidden sm:inline text-gray-300 dark:text-gray-500">|</span>
|
||||
<div className="flex items-center gap-1 w-full sm:w-auto">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-3.5 w-3.5 text-blue-500 dark:text-blue-400 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
|
||||
</svg>
|
||||
<span>Ctrl/Cmd+滚轮缩放</span>
|
||||
<span>推荐电脑操作,上色更精准</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2204,6 +2204,7 @@ export default function Home() {
|
||||
onClearSelection={() => setMagnifierSelectionArea(null)}
|
||||
isFloatingActive={activeFloatingTool === 'magnifier'}
|
||||
onActivateFloating={handleActivateMagnifier}
|
||||
highlightColorKey={highlightColorKey}
|
||||
/>
|
||||
|
||||
{/* 放大镜选择覆盖层 */}
|
||||
|
||||
@@ -15,6 +15,7 @@ interface MagnifierToolProps {
|
||||
onClearSelection: () => void;
|
||||
isFloatingActive: boolean;
|
||||
onActivateFloating: () => void;
|
||||
highlightColorKey?: string | null;
|
||||
}
|
||||
|
||||
interface SelectionArea {
|
||||
@@ -34,7 +35,8 @@ const MagnifierTool: React.FC<MagnifierToolProps> = ({
|
||||
selectionArea,
|
||||
onClearSelection,
|
||||
isFloatingActive,
|
||||
onActivateFloating
|
||||
onActivateFloating,
|
||||
highlightColorKey
|
||||
}) => {
|
||||
// 计算初始位置,确保在屏幕中央
|
||||
const getInitialPosition = () => ({
|
||||
@@ -102,6 +104,17 @@ const MagnifierTool: React.FC<MagnifierToolProps> = ({
|
||||
magnifiedCellSize
|
||||
);
|
||||
|
||||
// 如果有高亮颜色且当前像素不是目标颜色,添加灰度蒙版
|
||||
if (highlightColorKey && pixel.color.toUpperCase() !== highlightColorKey.toUpperCase()) {
|
||||
ctx.fillStyle = 'rgba(0, 0, 0, 0.6)'; // 60% 透明度的黑色蒙版,与预览画布一致
|
||||
ctx.fillRect(
|
||||
canvasCol * magnifiedCellSize,
|
||||
canvasRow * magnifiedCellSize,
|
||||
magnifiedCellSize,
|
||||
magnifiedCellSize
|
||||
);
|
||||
}
|
||||
|
||||
// 绘制网格线
|
||||
ctx.strokeStyle = '#e0e0e0';
|
||||
ctx.lineWidth = 1;
|
||||
@@ -114,7 +127,7 @@ const MagnifierTool: React.FC<MagnifierToolProps> = ({
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [selectionArea, mappedPixelData, getSelectionDimensions]);
|
||||
}, [selectionArea, mappedPixelData, getSelectionDimensions, highlightColorKey]);
|
||||
|
||||
// 处理放大视图点击
|
||||
const handleMagnifiedClick = useCallback((event: React.MouseEvent<HTMLCanvasElement>) => {
|
||||
|
||||
Reference in New Issue
Block a user