mirror of
https://github.com/ankitects/anki.git
synced 2025-11-08 21:57:12 -05:00
* fix: blur in io, remove panzoom and use fabricjs for panzoom - remove panzoom - implement panzoom using fabricjs - set background image for canvas - add bounding rect for canvas - draw or add point inside in bounding rect - update zoom tool * support pinch to zoom on mobile client * fix lagging of canvas, zoom in draw mode * panning in touch events
24 lines
916 B
TypeScript
24 lines
916 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
import type { GetImageOcclusionNoteResponse_ImageOcclusion } from "@tslib/anki/image_occlusion_pb";
|
|
import type { fabric } from "fabric";
|
|
import { extractShapesFromClozedField } from "image-occlusion/shapes/from-cloze";
|
|
|
|
import { addShape, addShapeGroup } from "./from-shapes";
|
|
import { redraw } from "./lib";
|
|
|
|
export const addShapesToCanvasFromCloze = (
|
|
canvas: fabric.Canvas,
|
|
boundingBox: fabric.Rect,
|
|
occlusions: GetImageOcclusionNoteResponse_ImageOcclusion[],
|
|
): void => {
|
|
for (const shapeOrShapes of extractShapesFromClozedField(occlusions)) {
|
|
if (Array.isArray(shapeOrShapes)) {
|
|
addShapeGroup(canvas, boundingBox, shapeOrShapes);
|
|
} else {
|
|
addShape(canvas, boundingBox, shapeOrShapes);
|
|
}
|
|
}
|
|
redraw(canvas);
|
|
};
|