import PSPoint from "./PSPoint" ; import { PSStrokeIface } from "./PSStroke" ; export type FabricPointerEvent = TouchEvent | MouseEvent | PointerEvent ; export interface FabricEvent { e : FabricPointerEvent ; pointer : FabricPointer ; } export interface FabricPointer { x : number ; y : number ; } export function isPSStroke ( object ) { return object && object [ "type" ] === "PSStroke" ; } export function isPSPoint ( object ) { return object && object [ "type" ] === "PSPoint" ; } export function getPressure ( ev , fallbackValue = 0.5 ) { if ( ev [ "touches" ] && ev [ "touches" ] . length > 0 ) { return ( < TouchEvent > ev ) . touches [ 0 ] . force ; } if ( ev [ "pointerType" ] === "mouse" || typeof ev [ "pressure" ] !== "number" ) { return fallbackValue ; } if ( ev [ "pointerType" ] === "touch" && ( < PointerEvent > ev ) . pressure === 0 ) { return fallbackValue ; } return ( < PointerEvent > ev ) . pressure ; }