import paper from 'paper' ; import { StrokeJoinType , PathType , StrokeCapType , offsetPath , offsetStroke } from './offset_core' ; export interface OffsetOptions { join ? : StrokeJoinType ; cap ? : StrokeCapType ; limit ? : number ; insert ? : boolean ; } export class PaperOffset { public static offset ( path , offset , options ? ) { options = options || { } ; const newPath = offsetPath ( path , offset , options . join || 'miter' , options . limit || 10 ) ; if ( options . insert === undefined ) { options . insert = true ; } if ( options . insert ) { ( path . parent || paper . project . activeLayer ) . addChild ( newPath ) ; } return newPath ; } public static offsetStroke ( path , offset , options ? ) { options = options || { } ; const newPath = offsetStroke ( path , offset , options . join || 'miter' , options . cap || 'butt' , options . limit || 10 ) ; if ( options . insert === undefined ) { options . insert = true ; } if ( options . insert ) { ( path . parent || paper . project . activeLayer ) . addChild ( newPath ) ; } return newPath ; } } deprecated export default function ExtendPaperJs ( paperNs ) { paperNs . Path . prototype . offset = function ( offset , options ? ) { return PaperOffset . offset ( this , offset , options ) ; } ; paperNs . Path . prototype . offsetStroke = function ( offset , options ? ) { return PaperOffset . offsetStroke ( this , offset , options ) ; } ; paperNs . CompoundPath . prototype . offset = function ( offset , options ? ) { return PaperOffset . offset ( this , offset , options ) ; } ; paperNs . CompoundPath . prototype . offsetStroke = function ( offset , options ? ) { return PaperOffset . offsetStroke ( this , offset , options ) ; } ; }