目前只能做到放大...
const [magnifier, setMagnifier] = useState(false); //是否放大中
const [initScale, setInitScale] = useState(1); // 缩放尺寸
const dramImageByScale = (scale: number) => {
const canvas = canvasRef.current;
const ctx = canvas.getContext("2d");
let imgWidth = canvas.width;
let imgHeight = canvas.height;
canvas.width = imgWidth;
canvas.height = imgHeight;
const width = imgWidth * scale;
const height = imgHeight * scale;
const sx = canvas.width / 2 - width / 2; //x坐标
const sy = canvas.height / 2 - height / 2; //y坐标
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.drawImage(savedData, sx, sy, width, height);
};
const handleMouseUp = (event: any) => {
...
case "magnifier":
dramImageByScale(initScale);
break;
};
const handleMouseDown = (event: any) => {
...
switch (tool) {
...
case "magnifier":
if (magnifier) {
setInitScale((prev) => (prev -= 0.1));
} else {
setInitScale((prev) => (prev += 0.1));
}
setMagnifier(!magnifier);
saveCanvas();
break;
default:
break;
}
};
<<: [Day25] 忘记压缩档密码怎麽办? 用Python多重处理快速破解压缩档密码!
>>: Unity与Photon的新手相遇旅途 | Day10-角色攻击
恩..这边主要是自己的笔记 自己最近想弄一些作品 MVC是已经会的东西 於是想自学一下Angular...
日期时间组件 在进入较进阶的组件内容之前,我们在介绍一下有关日期与时间的组件内容。在表单输入或是报表...
昨天我们已经将前置作业,也就是 URL Types、AppDelegate.swift 完成了,今天...
7+1 Sass 设计模式: https://gist.github.com/rveitch/84c...
Apiary 结合 Github 版本控制很方便。 今日要点: 》Apiary 建立专案介绍 》A...