提交 065e5760 编写于 作者: Q qq_41923622

Thu Feb 6 17:43:00 CST 2025 inscode

上级 408eed0f
......@@ -130,23 +130,33 @@ export const useInit = ({ url }: IProps) => {
imageUrl: string = '',
justBackground: boolean = false,
callback?: () => void,
annotationsData?: any,
) => {
const canvas = canvasInstanceRef.current;
if (imageUrl.trim() && canvas && wrapperInstanceRef.current) {
const { height } = wrapperInstanceRef.current.getBoundingClientRect();
imageInstanceRef.current = fabric.Image.fromURL(
imageUrl,
(oImg: any) => {
const center = canvas.getCenter();
const imgHeight = oImg.height;
/** 图片过大,使其大小正好跟容器一致 */
oImg.scale(height / imgHeight);
/** 使得图片在canvas中间 */
oImg.set({
left: center.left - (oImg.width * (height / imgHeight)) / 2,
top: center.top - (oImg.height * (height / imgHeight)) / 2,
});
const center = canvas.getCenter();
const imgHeight = oImg.height;
/** 图片过大,使其大小正好跟容器一致 */
oImg.scale(height / imgHeight);
if(annotationsData){
}else{
/** 使得图片在canvas中间 */
oImg.set({
left: center.left - (oImg.width * (height / imgHeight)) / 2,
top: center.top - (oImg.height * (height / imgHeight)) / 2,
});
}
/** 不让直接操作图片 */
oImg.selectable = false;
oImg.id = WORK_SPACE_ID;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册