import { Point , Rectangle } from "./Point" ; import * as React from "react" ; import { StandardLonghandProperties , Properties } from "csstype" ; type Omit < T , K > = Pick < T , Exclude < keyof T , K > > ; function omit < T , K extends keyof T > ( obj , keys ) { const newObj = { } as any ; for ( const [ key , val ] of Object . entries ( obj ) ) { if ( ! keys . includes ( key as K ) ) { ( newObj as any ) [ key ] = val ; } } return newObj ; } export interface SvgAttributes < T > extends React . DOMAttributes < T > { stroke ? : string ; fill ? : string ; className ? : string ; style ? : Properties ; pointerEvents ? : "none" | "auto" | "initial" ; } export function SvgText ( props ) { return ( < text x = { props . position . x } y = { props . position . y } ref = { props . childRef } { ... omit ( props , [ "position" , "childRef" ] ) } />); } export function SvgCircle ( props ) { return ( < circle cx = { props . center . x } cy = { props . center . y } r = { props . radius } ref = { props . childRef } { ... omit ( props , [ "center" , "radius" , "childRef" ] ) } />); } export function SvgLine ( props ) { return ( < line x1 = { props . start . x } y1 = { props . start . y } x2 = { props . end . x } y2 = { props . end . y } { ... omit ( props , [ "end" , "start" ] ) } />); } export function SvgRect ( props ) { const r = props . rectangle ; return ( < rect x = { r . topLeft . x } y = { r . topLeft . y } width = { r . size . x } height = { r . size . y } { ... omit ( props , [ "rectangle" ] ) } />); } export function Svg ( props ) { return ( < svg x = { props . position . x } y = { props . position . y } { ... omit ( props , [ "position" ] ) } />); }