Skip to content

Commit

Permalink
chore: Minor refactor. #1597
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Nov 3, 2022
1 parent 62ef33b commit e024b2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions ui/src/image_annotator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MockedRenderingContext extends window.CanvasRenderingContext2D {
const
name = 'image_annotator',
rect = { shape: { rect: { x1: 10, x2: 100, y1: 10, y2: 100 } }, tag: 'person' },
polygon = { shape: { polygon: { items: [{ x: 105, y: 100 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
polygon = { shape: { polygon: { vertices: [{ x: 105, y: 100 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
items = [rect, polygon],
model: ImageAnnotator = {
name,
Expand Down Expand Up @@ -291,7 +291,7 @@ describe('ImageAnnotator.tsx', () => {
fireEvent.click(canvasEl, { clientX: 10, clientY: 10 })

expect(wave.args[name]).toMatchObject([
{ tag: 'person', shape: { polygon: { items: [{ x: 10, y: 10 }, { x: 20, y: 20 }, { x: 30, y: 30 },] } } },
{ tag: 'person', shape: { polygon: { vertices: [{ x: 10, y: 10 }, { x: 20, y: 20 }, { x: 30, y: 30 },] } } },
...items
])
})
Expand All @@ -309,7 +309,7 @@ describe('ImageAnnotator.tsx', () => {
fireEvent.click(canvasEl, { clientX: 10, clientY: 10 })

expect(wave.args[name]).toMatchObject([
{ tag: 'object', shape: { polygon: { items: [{ x: 10, y: 10 }, { x: 20, y: 20 }, { x: 30, y: 30 },] } } },
{ tag: 'object', shape: { polygon: { vertices: [{ x: 10, y: 10 }, { x: 20, y: 20 }, { x: 30, y: 30 },] } } },
...items
])
})
Expand Down Expand Up @@ -351,7 +351,7 @@ describe('ImageAnnotator.tsx', () => {
fireEvent.click(canvasEl, { clientX: 240, clientY: 160 })
expect(wave.args[name]).toMatchObject([
rect,
{ shape: { polygon: { items: [{ x: 105, y: 100 }, { x: 240, y: 100 }, { x: 240, y: 160 }, { x: 240, y: 220 },] } }, tag: 'person' }
{ shape: { polygon: { vertices: [{ x: 105, y: 100 }, { x: 240, y: 100 }, { x: 240, y: 160 }, { x: 240, y: 220 },] } }, tag: 'person' }
])
})

Expand Down Expand Up @@ -405,7 +405,7 @@ describe('ImageAnnotator.tsx', () => {

expect(wave.args[name]).toMatchObject([
rect,
{ shape: { polygon: { items: [{ x: 115, y: 110 }, { x: 250, y: 110 }, { x: 250, y: 230 }] } }, tag: 'person' },
{ shape: { polygon: { vertices: [{ x: 115, y: 110 }, { x: 250, y: 110 }, { x: 250, y: 230 }] } }, tag: 'person' },
])
})

Expand Down Expand Up @@ -435,7 +435,7 @@ describe('ImageAnnotator.tsx', () => {

expect(wave.args[name]).toMatchObject([
rect,
{ shape: { polygon: { items: [{ x: 100, y: 200 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
{ shape: { polygon: { vertices: [{ x: 100, y: 200 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
])
})

Expand All @@ -452,7 +452,7 @@ describe('ImageAnnotator.tsx', () => {

expect(wave.args[name]).toMatchObject([
rect,
{ shape: { polygon: { items: [{ x: 100, y: 200 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
{ shape: { polygon: { vertices: [{ x: 100, y: 200 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
])
})

Expand All @@ -469,7 +469,7 @@ describe('ImageAnnotator.tsx', () => {

expect(wave.args[name]).toMatchObject([
rect,
{ shape: { polygon: { items: [{ x: 100, y: 200 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
{ shape: { polygon: { vertices: [{ x: 100, y: 200 }, { x: 240, y: 100 }, { x: 240, y: 220 },] } }, tag: 'person' },
])

fireEvent.click(canvasEl, { clientX: 180, clientY: 150 })
Expand All @@ -479,7 +479,7 @@ describe('ImageAnnotator.tsx', () => {

expect(wave.args[name]).toMatchObject([
rect,
{ shape: { polygon: { items: [{ x: 110, y: 210 }, { x: 250, y: 110 }, { x: 250, y: 230 },] } }, tag: 'person' },
{ shape: { polygon: { vertices: [{ x: 110, y: 210 }, { x: 250, y: 110 }, { x: 250, y: 230 },] } }, tag: 'person' },
])
})
})
Expand Down
2 changes: 1 addition & 1 deletion ui/src/image_annotator_polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class PolygonAnnotator {
if (this.isIntersectingFirstPoint(cursor_x, cursor_y)) {
const { x, y } = this.currPolygonPoints[0]
this.drawLine(x, y)
const newPolygon = { shape: { polygon: { items: [...this.currPolygonPoints] } }, tag }
const newPolygon = { shape: { polygon: { vertices: [...this.currPolygonPoints] } }, tag }
this.currPolygonPoints = []
return newPolygon
}
Expand Down

0 comments on commit e024b2c

Please sign in to comment.