DefinitelyTyped/types/svg-intersections/svg-intersections-tests.ts
William Bergeron-Drouin eb680b04ff Added types for svg-intersections (#39899)
* Generated svg-intersections files using npx

* Added base typings for shape method with conditional second argument type

* Added missing types in SvgProperties

* Added basic Shape interface

* Added types for intersect function

* Refactored intersection to interface and added typings to Matrix2D

* Linted index.d.ts

* Added line test

* Added tests for rect, circle, ellipse & polygon

* Added test for path

* Rectangle rx&ry should be optional

* Added intersections test

* Replaced unnecessary typeof with generic type
2019-11-01 15:01:47 -07:00

12 lines
572 B
TypeScript

import { intersect, shape } from 'svg-intersections';
const line = shape('line', {x1: 0, y1: 0, x2: 2, y2: 3});
const rect = shape('rect', {x: 0, y: 0, width: 200, height: 100});
const rectWithOptional = shape('rect', {x: 0, y: 0, width: 200, height: 100, rx: 4, ry: 4});
const circle = shape('circle', {cx: 0, cy: 0, r: 100});
const ellipse = shape('ellipse', {rx: 100, ry: 150, cx: 0, cy: 0});
const polygon = shape('polygon', {points: '-5,0 0,10 5,0 0,-10'});
const path = shape('path', {d: 'M 10 10 h 80 v 80 h -80 Z'});
const intersections = intersect(line, rect);