Skip to content

Commit 16a028b

Browse files
committed
minor flow fixes
1 parent 01edfd4 commit 16a028b

File tree

4 files changed

+45
-24
lines changed

4 files changed

+45
-24
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"@semantic-release/git": "^9.0.0",
1111
"get-image-data": "^3.0.1",
1212
"material-survey": "^1.0.34",
13+
"mmgc1-cpp": "^1.0.0",
1314
"moment": "^2.23.0",
1415
"react-full-screen": "^0.2.4",
1516
"react-hotkeys": "^2.0.0",

src/ImageCanvas/index.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Props = {
4646
videoPlaying?: boolean,
4747
mask?: ImageData,
4848
maskVersion?: any,
49+
fullImageSegmentationMode?: boolean,
4950

5051
onChangeRegion: (Region) => any,
5152
onBeginRegionEdit: (Region) => any,
@@ -62,6 +63,7 @@ type Props = {
6263
duration?: number,
6364
}) => any,
6465
onChangeVideoTime: (number) => any,
66+
onChangeVideoPlaying?: Function,
6567
}
6668

6769
const getDefaultMat = () => Matrix.from(1, 0, 0, 1, -10, -10)
@@ -237,9 +239,9 @@ export const ImageCanvas = ({
237239
)) {
238240
switch (region.type) {
239241
case "point": {
240-
if(!fullImageSegmentationMode){
242+
if (!fullImageSegmentationMode) {
241243
context.save()
242-
244+
243245
context.beginPath()
244246
context.strokeStyle = region.color
245247
context.moveTo(region.x * iw - 10, region.y * ih)
@@ -254,20 +256,20 @@ export const ImageCanvas = ({
254256
context.arc(region.x * iw, region.y * ih, 5, 0, 2 * Math.PI)
255257
context.stroke()
256258
context.restore()
257-
}else {
259+
} else {
258260
const length = 4
259261
context.save()
260262

261263
context.beginPath()
262264
context.strokeStyle = region.color
263265

264-
context.moveTo(region.x * iw, region.y * ih+ length)
266+
context.moveTo(region.x * iw, region.y * ih + length)
265267
context.lineTo(region.x * iw + length, region.y * ih)
266-
context.moveTo(region.x * iw, region.y * ih- length)
268+
context.moveTo(region.x * iw, region.y * ih - length)
267269
context.lineTo(region.x * iw + length, region.y * ih)
268-
context.moveTo(region.x * iw, region.y * ih-length)
270+
context.moveTo(region.x * iw, region.y * ih - length)
269271
context.lineTo(region.x * iw - length, region.y * ih)
270-
context.moveTo(region.x * iw, region.y * ih+length)
272+
context.moveTo(region.x * iw, region.y * ih + length)
271273
context.lineTo(region.x * iw - length, region.y * ih)
272274
context.stroke()
273275
context.restore()
@@ -478,7 +480,14 @@ export const ImageCanvas = ({
478480
{...mouseEvents}
479481
>
480482
<>
481-
{mask && <ImageMask maskVersion={maskVersion} videoPlaying={videoPlaying} imagePosition={imagePosition} imageData={mask} />}
483+
{mask && (
484+
<ImageMask
485+
maskVersion={maskVersion}
486+
videoPlaying={videoPlaying}
487+
imagePosition={imagePosition}
488+
imageData={mask}
489+
/>
490+
)}
482491
<canvas className={classes.canvas} ref={canvasEl} />
483492
<VideoOrImageCanvasBackground
484493
videoPlaying={videoPlaying}

src/ImageMask/index.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
// @flow
22

33
import React, { useState, useEffect, useMemo } from "react"
4-
export default ({ imageData,
5-
imagePosition,
6-
videoPlaying, maskVersion,
7-
pointerEvents = "none",
8-
opacity = 0.5,
9-
zIndex = 999,
10-
position = 'absolute'
11-
}) => {
4+
5+
import mmgc from "mmgc1-cpp"
6+
7+
export default ({
8+
classPoints,
9+
imageData,
10+
imagePosition,
11+
videoPlaying,
12+
maskVersion,
13+
pointerEvents = "none",
14+
opacity = 0.5,
15+
zIndex = 999,
16+
position = "absolute",
17+
}) => {
1218
const [canvasRef, setCanvasRef] = useState(null)
1319

1420
useEffect(() => {
@@ -28,7 +34,7 @@ export default ({ imageData,
2834
zIndex,
2935
position,
3036
opacity,
31-
pointerEvents
37+
pointerEvents,
3238
}
3339
}, [
3440
imagePosition.topLeft.x,
@@ -38,7 +44,7 @@ export default ({ imageData,
3844
zIndex,
3945
position,
4046
opacity,
41-
pointerEvents
47+
pointerEvents,
4248
])
4349

4450
return (

yarn.lock

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10820,6 +10820,11 @@ mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@
1082010820
dependencies:
1082110821
minimist "0.0.8"
1082210822

10823+
mmgc1-cpp@^1.0.0:
10824+
version "1.0.0"
10825+
resolved "https://registry.yarnpkg.com/mmgc1-cpp/-/mmgc1-cpp-1.0.0.tgz#59b4532c82958733049e818c6831c7f7aa7cc1b7"
10826+
integrity sha512-QqIkVp428kdTeV0X8nnAVFWq6sutTZrb/hG0eMDQNv4m3cLkMoHBmAe7x8V8/m/NOT5ujMRKC8zMjZz3odqJvQ==
10827+
1082310828
moment@^2.23.0:
1082410829
version "2.24.0"
1082510830
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
@@ -12771,16 +12776,16 @@ preserve@^0.2.0:
1277112776
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
1277212777
integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=
1277312778

12774-
prettier@2.0.2:
12775-
version "2.0.2"
12776-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.2.tgz#1ba8f3eb92231e769b7fcd7cb73ae1b6b74ade08"
12777-
integrity sha512-5xJQIPT8BraI7ZnaDwSbu5zLrB6vvi8hVV58yHQ+QK64qrY40dULy0HSRlQ2/2IdzeBpjhDkqdcFBnFeDEMVdg==
12778-
1277912779
prettier@^1.16.4:
1278012780
version "1.19.1"
1278112781
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
1278212782
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
1278312783

12784+
prettier@^2.0.5:
12785+
version "2.0.5"
12786+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
12787+
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==
12788+
1278412789
pretty-bytes@^4.0.2:
1278512790
version "4.0.2"
1278612791
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
@@ -13324,7 +13329,7 @@ react-helmet-async@^1.0.2:
1332413329
react-fast-compare "2.0.4"
1332513330
shallowequal "1.1.0"
1332613331

13327-
react-hotkeys@2.0.0:
13332+
react-hotkeys@2.0.0, react-hotkeys@^2.0.0:
1332813333
version "2.0.0"
1332913334
resolved "https://registry.yarnpkg.com/react-hotkeys/-/react-hotkeys-2.0.0.tgz#a7719c7340cbba888b0e9184f806a9ec0ac2c53f"
1333013335
integrity sha512-3n3OU8vLX/pfcJrR3xJ1zlww6KS1kEJt0Whxc4FiGV+MJrQ1mYSYI3qS/11d2MJDFm8IhOXMTFQirfu6AVOF6Q==

0 commit comments

Comments
 (0)