@lunit/is-polygon-area-greater-than-area
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "@lunit/is-polygon-area-greater-than-area", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Test is polygon area greater than area", | ||
"author": { | ||
"name": "Seoyeon Lee", | ||
"email": "seoyeon.lee@lunit.io" | ||
}, | ||
"author": "Seoyeon Lee <seoyeon.lee@lunit.io>", | ||
"repository": "lunit-io/frontend-components", | ||
@@ -14,3 +11,4 @@ "license": "MIT", | ||
}, | ||
"main": "index.js" | ||
"main": "index.js", | ||
"typings": "index.d.ts" | ||
} |
146
README.md
@@ -1,142 +0,14 @@ | ||
# Install | ||
# `@lunit/is-polygon-area-greater-than-area` | ||
```sh | ||
npm install @lunit/is-polygon-area-greater-than-area | ||
``` | ||
Polygon (`[number, number][]`)의 면적이 일정 이하인지 검증한다. | ||
# Sample Codes | ||
Annotation Tool, OPT와 같이 사용자에게 Annotation을 입력 받을때 | ||
잘못된 Polygon이 입력되지 않도록 방지하는데 사용한다. | ||
## Stories | ||
<https://frontend-components-handbook.netlify.com/#/is-polygon-area-greater-than-area> | ||
<!-- import **/*.stories.{ts,tsx} --title-tag h3 --> | ||
# Install | ||
### \_\_stories\_\_/isPolygonAreaGreaterThenArea.stories.tsx | ||
```tsx | ||
import { | ||
CornerstoneImage, | ||
CornerstoneSingleImage, | ||
InsightViewer, | ||
InsightViewerContainer, | ||
installWADOImageLoader, | ||
Point, | ||
unloadWADOImage, | ||
useInsightViewerSync, | ||
UserContourDrawer, | ||
} from '@lunit/insight-viewer'; | ||
import { isPolygonAreaGreaterThanArea } from '@lunit/is-polygon-area-greater-than-area'; | ||
import { storiesOf } from '@storybook/react'; | ||
import React, { ReactNode, useCallback, useState } from 'react'; | ||
installWADOImageLoader(); | ||
const resetTime: number = Date.now(); | ||
const image: CornerstoneImage = new CornerstoneSingleImage(`wadouri:https://lunit-io.github.io/frontend-fixtures/dcm-files/series/CT000010.dcm`, {unload: unloadWADOImage}); | ||
function doNothing() { | ||
// DO NOTHING | ||
} | ||
function Sample() { | ||
const width: number = 400; | ||
const height: number = 500; | ||
const [interactionElement, setInteractionElement] = useState<HTMLElement | null>(null); | ||
const { | ||
cornerstoneRenderData, | ||
updateCornerstoneRenderData, | ||
} = useInsightViewerSync(); | ||
const [checkResult, setCheckResult] = useState<ReactNode>(null); | ||
const check = useCallback((polygon: Point[]) => { | ||
const result: boolean = isPolygonAreaGreaterThanArea(polygon); | ||
setCheckResult(( | ||
<div> | ||
<h3><span role="img" aria-label="polygon">🧬</span> POLYGON</h3> | ||
<pre><code>{JSON.stringify(polygon)}</code></pre> | ||
<p><span role="img" aria-label="question">🤷♂️</span> IS GREATER THAN AREA({100})? → {result ? 'YES' : 'NO'}</p> | ||
</div> | ||
)); | ||
}, []); | ||
return ( | ||
<div> | ||
<InsightViewerContainer ref={setInteractionElement} width={width} height={height}> | ||
<InsightViewer width={width} | ||
height={height} | ||
invert={false} | ||
flip={false} | ||
pan={false} | ||
adjust={false} | ||
zoom={false} | ||
resetTime={resetTime} | ||
image={image} | ||
updateCornerstoneRenderData={updateCornerstoneRenderData}/> | ||
{ | ||
cornerstoneRenderData && | ||
<UserContourDrawer width={width} | ||
height={height} | ||
contours={[]} | ||
draw={interactionElement} | ||
onFocus={doNothing} | ||
onAdd={check} | ||
onRemove={doNothing} | ||
cornerstoneRenderData={cornerstoneRenderData}/> | ||
} | ||
</InsightViewerContainer> | ||
<div> | ||
<pre><code>{checkResult}</code></pre> | ||
</div> | ||
</div> | ||
); | ||
} | ||
storiesOf('in-polygon-area-greater-than-area', module) | ||
.add('isPolygonAreaGreaterThanArea()', () => <Sample/>); | ||
``` | ||
<!-- importend --> | ||
## Tests | ||
<!-- import __tests__/*.{ts,tsx} --title-tag h3 --> | ||
### \_\_tests\_\_/isPolygonAreaGreaterThanArea.test.ts | ||
```ts | ||
import { isPolygonAreaGreaterThanArea } from '@lunit/is-polygon-area-greater-than-area'; | ||
describe('isPolygonAreaGreaterThanArea()', () => { | ||
test('Polygon의 Area는 100보다 크다', () => { | ||
expect(isPolygonAreaGreaterThanArea([[293.12, 344.32], [293.12, 344.32], [290.56, 345.6], [288, 348.16], [285.44, 350.72], [282.88, 353.28000000000003], [280.32, 357.12], [273.92, 362.24], [270.08, 367.36], [264.96, 371.2], [262.4, 373.76], [257.28000000000003, 377.6], [254.72, 380.16], [252.16, 382.72], [250.88, 384], [249.6, 385.28000000000003], [248.32, 385.28000000000003], [248.32, 385.28000000000003], [247.04, 386.56], [245.76, 386.56], [243.20000000000002, 386.56], [240.64000000000001, 386.56], [235.52, 385.28000000000003], [231.68, 384], [227.84, 381.44], [224, 377.6], [218.88, 375.04], [217.6, 373.76], [215.04, 371.2], [212.48000000000002, 368.64], [211.20000000000002, 366.08], [209.92000000000002, 362.24], [209.92000000000002, 360.96000000000004], [209.92000000000002, 358.40000000000003], [209.92000000000002, 355.84000000000003], [209.92000000000002, 354.56], [211.20000000000002, 350.72], [212.48000000000002, 348.16], [213.76, 346.88], [213.76, 344.32], [215.04, 343.04], [216.32, 340.48], [216.32, 340.48], [217.6, 339.2], [217.6, 337.92], [218.88, 337.92], [218.88, 337.92], [220.16, 336.64], [221.44, 336.64], [224, 335.36], [226.56, 334.08], [234.24, 332.8], [239.36, 330.24], [247.04, 327.68], [253.44, 326.40000000000003], [259.84000000000003, 325.12], [263.68, 323.84000000000003], [267.52, 322.56], [271.36, 321.28000000000003], [273.92, 321.28000000000003], [276.48, 321.28000000000003], [276.48, 321.28000000000003], [277.76, 321.28000000000003], [280.32, 321.28000000000003], [282.88, 321.28000000000003]])) | ||
.toBeTruthy(); | ||
expect(isPolygonAreaGreaterThanArea([[322.56, 71.68], [322.56, 71.68], [316.16, 74.24000000000001], [309.76, 75.52000000000001], [302.08, 78.08000000000001], [295.68, 80.64000000000001], [288, 84.47999999999999], [284.16, 87.03999999999999], [279.04, 90.88], [272.64, 96], [270.08, 99.84], [267.52, 102.4], [267.52, 107.52000000000001], [267.52, 110.08000000000001], [268.8, 112.64000000000001], [272.64, 116.47999999999999], [282.88, 121.6], [293.12, 125.44], [302.08, 128], [312.32, 129.28], [321.28000000000003, 129.28], [334.08, 129.28], [339.2, 130.56], [349.44, 129.28], [357.12, 128], [360.96, 126.72], [366.08, 125.44], [371.2, 124.16], [372.48, 122.88], [375.04, 120.32], [377.6, 117.75999999999999], [377.6, 115.20000000000002], [377.6, 112.64000000000001], [377.6, 107.52000000000001], [377.6, 104.96000000000001], [376.32, 101.12], [373.76, 98.56], [372.48, 94.72], [371.2, 92.16], [368.64, 89.6], [367.36, 88.32], [367.36, 87.03999999999999], [366.08, 85.75999999999999], [366.08, 85.75999999999999], [364.8, 84.47999999999999]])) | ||
.toBeTruthy(); | ||
expect(isPolygonAreaGreaterThanArea([[408.32, 177.92000000000002], [408.32, 177.92000000000002], [407.04, 177.92000000000002], [405.76, 179.20000000000002], [404.48, 180.48000000000002], [401.92, 181.76], [400.64, 183.04], [399.36, 185.6], [396.8, 186.88], [396.8, 190.72], [395.52, 194.56], [395.52, 195.84000000000003], [395.52, 198.39999999999998], [395.52, 200.95999999999998], [396.8, 200.95999999999998], [398.08, 203.51999999999998], [399.36, 204.8], [401.92, 204.8], [404.48, 206.07999999999998], [405.76, 206.07999999999998], [409.6, 206.07999999999998], [413.44, 206.07999999999998], [416, 204.8], [417.28000000000003, 204.8], [421.12, 203.51999999999998], [422.40000000000003, 202.24], [423.68, 200.95999999999998], [424.96000000000004, 200.95999999999998], [426.24, 200.95999999999998], [426.24, 199.68], [426.24, 199.68], [427.52, 199.68], [427.52, 198.39999999999998], [427.52, 198.39999999999998], [427.52, 197.12], [427.52, 197.12], [427.52, 195.84000000000003], [427.52, 195.84000000000003], [427.52, 194.56], [427.52, 193.28000000000003], [427.52, 193.28000000000003], [427.52, 193.28000000000003], [427.52, 192], [427.52, 192], [427.52, 192], [427.52, 190.72], [427.52, 190.72], [427.52, 189.44], [427.52, 189.44], [427.52, 188.16], [427.52, 186.88], [427.52, 186.88], [427.52, 186.88], [427.52, 185.6], [427.52, 185.6], [427.52, 185.6], [427.52, 185.6], [427.52, 184.32], [427.52, 184.32], [426.24, 183.04]])) | ||
.toBeTruthy(); | ||
expect(isPolygonAreaGreaterThanArea([[62.72, 371.2], [62.72, 371.2], [62.72, 371.2], [61.44, 371.2], [60.160000000000004, 371.2], [60.160000000000004, 371.2], [58.88, 371.2], [57.6, 372.48], [56.32, 373.76], [55.04, 375.04], [55.04, 376.32], [53.76, 376.32], [53.76, 377.6], [53.76, 378.88], [53.76, 380.16], [53.76, 381.44], [53.76, 381.44], [53.76, 382.72], [55.04, 382.72], [56.32, 384], [57.6, 384], [58.88, 384], [60.160000000000004, 384], [61.44, 384], [62.72, 384], [62.72, 384], [64, 384], [65.28, 384], [65.28, 384], [65.28, 384], [65.28, 384], [66.56, 384], [66.56, 382.72], [66.56, 382.72], [66.56, 382.72], [66.56, 382.72], [67.84, 382.72], [67.84, 382.72], [67.84, 381.44], [67.84, 381.44], [67.84, 380.16], [67.84, 378.88], [67.84, 378.88], [66.56, 377.6], [66.56, 376.32], [66.56, 376.32], [65.28, 375.04], [65.28, 375.04], [65.28, 375.04], [65.28, 375.04]])) | ||
.toBeTruthy(); | ||
}); | ||
test('Polygon의 Area는 100보다 작다', () => { | ||
expect(isPolygonAreaGreaterThanArea([[407.04, 336.64], [407.04, 336.64], [407.04, 337.92], [407.04, 339.2], [407.04, 339.2], [407.04, 340.48], [407.04, 340.48], [407.04, 341.76], [407.04, 341.76], [407.04, 341.76], [408.32, 341.76], [409.6, 343.04], [410.88, 343.04], [410.88, 343.04], [412.16, 343.04], [412.16, 343.04], [413.44, 343.04], [413.44, 343.04], [413.44, 343.04], [413.44, 343.04], [414.72, 343.04]])) | ||
.toBeFalsy(); | ||
expect(isPolygonAreaGreaterThanArea([[404.48, 350.72], [404.48, 352], [404.48, 352], [404.48, 352], [404.48, 352], [404.48, 353.28000000000003], [404.48, 353.28000000000003], [404.48, 353.28000000000003], [404.48, 353.28000000000003], [404.48, 353.28000000000003], [405.76, 354.56], [405.76, 354.56], [405.76, 354.56], [405.76, 354.56], [405.76, 354.56], [405.76, 354.56], [407.04, 354.56]])) | ||
.toBeFalsy(); | ||
expect(isPolygonAreaGreaterThanArea([[180.48, 453.12], [179.20000000000002, 453.12], [179.20000000000002, 453.12], [177.92000000000002, 453.12], [176.64000000000001, 453.12], [176.64000000000001, 453.12], [175.36, 453.12], [175.36, 454.4], [175.36, 454.4], [175.36, 455.68000000000006], [175.36, 455.68000000000006], [175.36, 456.96000000000004], [175.36, 456.96000000000004], [175.36, 456.96000000000004], [175.36, 458.24], [175.36, 458.24], [175.36, 458.24], [175.36, 459.52], [175.36, 459.52], [175.36, 459.52], [176.64000000000001, 459.52], [176.64000000000001, 459.52], [176.64000000000001, 459.52], [176.64000000000001, 458.24]])) | ||
.toBeFalsy(); | ||
}); | ||
}); | ||
``` | ||
<!-- importend --> | ||
```sh | ||
npm install @lunit/is-polygon-area-greater-than-area | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5
6179
14
1