@@ -30,8 +30,9 @@ const image = {
30
30
};
31
31
32
32
const polygons = [[[0 , 0 ], [1 , 0 ], [0 , 1 ]], [[2 , 0 ], [1 , 1 ], [0 , 2 ]]];
33
+ const damages = [{ damageType: " Scratch" , polygons, id }];
33
34
34
- < DamageHighlight image= {image} polygons = {polygons } / > ;
35
+ < DamageHighlight image= {image} damages = {damages } / > ;
35
36
```
36
37
37
38
The component's properties are from the result of an inspection. Both of them are a part of ` inspection.images ` .
@@ -160,46 +161,52 @@ Format an `image` to a classical [image](#image) object (cf. [example](#Example)
160
161
161
162
# Example
162
163
``` javascript
163
- import { usePolygons } from ' @monkvision/visualization' ;
164
- ```
165
-
166
- ``` javascript
167
- const oneImage = inspection .images [0 ]; // result from API
168
-
169
- const ref = useRef (null );
170
- const { getDamages , getImage } = usePolygons ();
171
- const options = {
172
- polygons: {
173
- opacity: 0.5 ,
174
- stroke: {
175
- color: ' green' ,
176
- strokeWidth: 50 ,
177
- }
178
- },
179
- label: {
180
- fontSize: 20 ,
181
- },
182
- background: {
183
- opacity: 0.35 ,
184
- },
185
- }
186
-
187
- const handleSaveImage = useCallback (async () => {
188
- const base64 = await ref .current .toImage ();
189
- save (base64);
190
- }, [ref]);
191
-
192
- const handlePressDamage = (damage ) => {
193
- console .log (damage);
164
+ import React , { useState , useEffect } from ' react' ;
165
+ import { DamageHighlight , useProps } from ' @monkvision/visualization' ;
166
+
167
+ export default function App () {
168
+ const oneImage = inspection .images [0 ]; // result from API
169
+
170
+ const ref = useRef (null );
171
+ const { getDamages , getImage } = useProps ();
172
+ const options = {
173
+ polygons: {
174
+ opacity: 0.5 ,
175
+ stroke: {
176
+ color: ' green' ,
177
+ strokeWidth: 50 ,
178
+ }
179
+ },
180
+ label: {
181
+ fontSize: 20 ,
182
+ },
183
+ background: {
184
+ opacity: 0.35 ,
185
+ },
186
+ }
187
+
188
+ const handleSaveImage = useCallback (async () => {
189
+ const base64 = await ref .current .toImage ();
190
+ save (base64);
191
+ }, [ref]);
192
+
193
+ const handlePressDamage = (damage ) => {
194
+ console .log (damage);
195
+ }
196
+
197
+ return (
198
+ < View>
199
+ < DamageHighlight
200
+ image= {getImage (oneImage)}
201
+ damages= {getDamages (oneImage, inspection .damages )}
202
+ options= {options}
203
+ width= {400 }
204
+ height= {180 }
205
+ onPressDamage= {console .log }
206
+ ref= {ref}
207
+ / >
208
+ < / View>
209
+ )
194
210
}
195
211
196
- < DamageHighlight
197
- image= {getImage (oneImage)}
198
- damages= {getDamages (oneImage, inspection .damages )}
199
- options= {options}
200
- width= {400 }
201
- height= {180 }
202
- onPressDamage= {console .log }
203
- ref= {ref}
204
- / >
205
212
```
0 commit comments