@annotorious/annotorious 3.0.0-rc.3 → 3.0.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Annotorious.d.ts +9 -7
- package/dist/Annotorious.d.ts.map +1 -1
- package/dist/AnnotoriousOpts.d.ts +7 -5
- package/dist/AnnotoriousOpts.d.ts.map +1 -1
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts +3 -2
- package/dist/annotation/SVGAnnotationLayerPointerEvent.d.ts.map +1 -1
- package/dist/annotation/editors/Handle.svelte.d.ts +1 -0
- package/dist/annotation/editors/editorsRegistry.d.ts +4 -3
- package/dist/annotation/editors/editorsRegistry.d.ts.map +1 -1
- package/dist/annotation/editors/index.d.ts +1 -1
- package/dist/annotation/editors/index.d.ts.map +1 -1
- package/dist/annotation/tools/DrawingToolConfig.d.ts +2 -1
- package/dist/annotation/tools/drawingToolsRegistry.d.ts +5 -4
- package/dist/annotation/tools/drawingToolsRegistry.d.ts.map +1 -1
- package/dist/annotation/utils/responsive.d.ts +1 -1
- package/dist/annotation/utils/styling.d.ts +4 -3
- package/dist/annotation/utils/styling.d.ts.map +1 -1
- package/dist/annotation/utils/touch.d.ts.map +1 -1
- package/dist/annotorious.css +1 -1
- package/dist/annotorious.es.js +2461 -2193
- package/dist/annotorious.es.js.map +1 -1
- package/dist/annotorious.js +1 -1
- package/dist/annotorious.js.map +1 -1
- package/dist/index.d.ts +1 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/keyboardCommands.d.ts +3 -2
- package/dist/keyboardCommands.d.ts.map +1 -1
- package/dist/model/core/ImageAnnotation.d.ts +3 -2
- package/dist/model/core/Shape.d.ts +2 -1
- package/dist/model/core/ellipse/Ellipse.d.ts +2 -1
- package/dist/model/core/polygon/Polygon.d.ts +2 -1
- package/dist/model/core/rectangle/Rectangle.d.ts +2 -1
- package/dist/model/core/rectangle/rectangleUtils.d.ts +3 -2
- package/dist/model/core/shapeUtils.d.ts +3 -5
- package/dist/model/core/shapeUtils.d.ts.map +1 -1
- package/dist/model/w3c/W3CImageAnnotation.d.ts +12 -0
- package/dist/model/w3c/W3CImageAnnotation.d.ts.map +1 -0
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts +6 -4
- package/dist/model/w3c/W3CImageFormatAdapter.d.ts.map +1 -1
- package/dist/model/w3c/fragment/FragmentSelector.d.ts +3 -3
- package/dist/model/w3c/fragment/FragmentSelector.d.ts.map +1 -1
- package/dist/model/w3c/index.d.ts +1 -0
- package/dist/model/w3c/index.d.ts.map +1 -1
- package/dist/model/w3c/svg/SVG.d.ts.map +1 -1
- package/dist/model/w3c/svg/SVGSelector.d.ts +3 -3
- package/dist/model/w3c/svg/SVGSelector.d.ts.map +1 -1
- package/dist/state/ImageAnnotationStore.d.ts +3 -2
- package/dist/state/ImageAnnotatorState.d.ts +5 -4
- package/dist/state/ImageAnnotatorState.d.ts.map +1 -1
- package/dist/state/spatialTree.d.ts +3 -2
- package/dist/state/spatialTree.d.ts.map +1 -1
- package/dist/themes/smart/setTheme.d.ts +4 -1
- package/dist/themes/smart/setTheme.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/Annotorious.css +9 -5
- package/src/Annotorious.ts +44 -32
- package/src/AnnotoriousOpts.ts +12 -7
- package/src/annotation/SVGAnnotationLayer.svelte +24 -16
- package/src/annotation/SVGAnnotationLayerPointerEvent.ts +1 -2
- package/src/annotation/Transform.ts +1 -1
- package/src/annotation/editors/Editor.svelte +10 -11
- package/src/annotation/editors/EditorMount.svelte +3 -3
- package/src/annotation/editors/Handle.svelte +66 -0
- package/src/annotation/editors/index.ts +2 -2
- package/src/annotation/editors/polygon/PolygonEditor.svelte +16 -16
- package/src/annotation/editors/rectangle/RectangleEditor.svelte +46 -43
- package/src/annotation/shapes/Ellipse.svelte +3 -3
- package/src/annotation/shapes/Polygon.svelte +3 -3
- package/src/annotation/shapes/Rectangle.svelte +3 -3
- package/src/annotation/tools/ToolMount.svelte +3 -3
- package/src/annotation/tools/drawingToolsRegistry.ts +2 -1
- package/src/annotation/tools/polygon/RubberbandPolygon.svelte +40 -13
- package/src/annotation/tools/rectangle/RubberbandRectangle.svelte +27 -11
- package/src/annotation/utils/responsive.ts +1 -1
- package/src/annotation/utils/styling.ts +5 -2
- package/src/annotation/utils/touch.ts +4 -1
- package/src/index.ts +22 -16
- package/src/keyboardCommands.ts +11 -7
- package/src/model/w3c/W3CImageAnnotation.ts +17 -0
- package/src/model/w3c/W3CImageFormatAdapter.ts +53 -21
- package/src/model/w3c/fragment/FragmentSelector.ts +5 -6
- package/src/model/w3c/index.ts +1 -0
- package/src/model/w3c/svg/SVG.ts +1 -2
- package/src/model/w3c/svg/SVGSelector.ts +11 -13
- package/src/state/ImageAnnotatorState.ts +3 -3
- package/src/state/spatialTree.ts +3 -2
- package/src/themes/dark/index.css +2 -2
- package/src/themes/light/index.css +2 -2
- package/src/themes/smart/setTheme.ts +10 -6
- package/dist/annotation/editors/Handle.d.ts +0 -14
- package/dist/annotation/editors/Handle.d.ts.map +0 -1
- package/src/annotation/editors/Handle.ts +0 -21
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Theme } from '../../AnnotoriousOpts';
|
|
2
|
+
|
|
1
3
|
export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
2
4
|
|
|
3
5
|
let canvas: HTMLCanvasElement;
|
|
@@ -6,7 +8,7 @@ export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
|
6
8
|
|
|
7
9
|
if (imageOrCanvas.nodeName === 'CANVAS') {
|
|
8
10
|
canvas = imageOrCanvas as HTMLCanvasElement;
|
|
9
|
-
context = canvas.getContext('2d', { willReadFrequently: true })
|
|
11
|
+
context = canvas.getContext('2d', { willReadFrequently: true })!;
|
|
10
12
|
} else {
|
|
11
13
|
const img = imageOrCanvas as HTMLImageElement;
|
|
12
14
|
// Copy image to in-memory canvas for processing
|
|
@@ -14,7 +16,7 @@ export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
|
14
16
|
canvas.width = img.width;
|
|
15
17
|
canvas.height = img.height;
|
|
16
18
|
|
|
17
|
-
context = canvas.getContext('2d', { willReadFrequently: true })
|
|
19
|
+
context = canvas.getContext('2d', { willReadFrequently: true })!;
|
|
18
20
|
context.drawImage(img, 0, 0, img.width, img.height);
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -35,12 +37,14 @@ export const sampleBrightness = (imageOrCanvas: HTMLElement) => {
|
|
|
35
37
|
return totalBrightness / 81;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
export const
|
|
40
|
+
export const detectTheme = (imageOrCanvas: HTMLElement) => {
|
|
39
41
|
const brightness = sampleBrightness(imageOrCanvas);
|
|
40
|
-
|
|
41
42
|
const theme = brightness > 0.6 ? 'dark' : 'light'
|
|
42
43
|
|
|
43
44
|
console.log(`[Annotorious] Image brightness: ${brightness.toFixed(1)}. Setting ${theme} theme.`);
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
}
|
|
46
|
+
return theme;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const setTheme = (imageOrCanvas: HTMLElement, container: HTMLElement, theme: Theme) =>
|
|
50
|
+
container.setAttribute('data-theme', theme === 'auto' ? detectTheme(imageOrCanvas) : theme);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type Handle = string;
|
|
2
|
-
export declare const Handle: {
|
|
3
|
-
(value: string | number): string;
|
|
4
|
-
SHAPE: string;
|
|
5
|
-
TOP: string;
|
|
6
|
-
RIGHT: string;
|
|
7
|
-
BOTTOM: string;
|
|
8
|
-
LEFT: string;
|
|
9
|
-
TOP_LEFT: string;
|
|
10
|
-
TOP_RIGHT: string;
|
|
11
|
-
BOTTOM_RIGHT: string;
|
|
12
|
-
BOTTOM_LEFT: string;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=Handle.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Handle.d.ts","sourceRoot":"","sources":["../../../src/annotation/editors/Handle.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B,eAAO,MAAM,MAAM;YAAW,MAAM,GAAG,MAAM;;;;;;;;;;CAAsB,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type Handle = string;
|
|
2
|
-
|
|
3
|
-
export const Handle = (value: string | number) => `HANDLE-${value}`;
|
|
4
|
-
|
|
5
|
-
Handle.SHAPE = 'SHAPE';
|
|
6
|
-
|
|
7
|
-
Handle.TOP = 'TOP';
|
|
8
|
-
|
|
9
|
-
Handle.RIGHT = 'RIGHT';
|
|
10
|
-
|
|
11
|
-
Handle.BOTTOM = 'BOTTOM';
|
|
12
|
-
|
|
13
|
-
Handle.LEFT = 'LEFT';
|
|
14
|
-
|
|
15
|
-
Handle.TOP_LEFT = 'TOP_LEFT';
|
|
16
|
-
|
|
17
|
-
Handle.TOP_RIGHT = 'TOP_RIGHT';
|
|
18
|
-
|
|
19
|
-
Handle.BOTTOM_RIGHT = 'BOTTOM_RIGHT';
|
|
20
|
-
|
|
21
|
-
Handle.BOTTOM_LEFT = 'BOTTOM_LEFT';
|