diff options
Diffstat (limited to 'src/new_fields/Doc.ts')
-rw-r--r-- | src/new_fields/Doc.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts index b875e7896..1b3c8b0b0 100644 --- a/src/new_fields/Doc.ts +++ b/src/new_fields/Doc.ts @@ -13,6 +13,7 @@ import { listSpec } from "./Schema"; import { ComputedField } from "./ScriptField"; import { BoolCast, Cast, FieldValue, NumCast, PromiseValue, StrCast, ToConstructor } from "./Types"; import { deleteProperty, getField, getter, makeEditable, makeReadOnly, setter, updateFunction } from "./util"; +import { intersectRect } from "../Utils"; export namespace Field { export function toKeyValueString(doc: Doc, key: string): string { @@ -614,6 +615,18 @@ export namespace Doc { }), 0); } + export function overlapping(doc: Doc, doc2: Doc, clusterDistance: number) { + var x2 = NumCast(doc2.x) - clusterDistance; + var y2 = NumCast(doc2.y) - clusterDistance; + var w2 = NumCast(doc2.width) + clusterDistance; + var h2 = NumCast(doc2.height) + clusterDistance; + var x = NumCast(doc.x) - clusterDistance; + var y = NumCast(doc.y) - clusterDistance; + var w = NumCast(doc.width) + clusterDistance; + var h = NumCast(doc.height) + clusterDistance; + return doc.z === doc2.z && intersectRect({ left: x, top: y, width: w, height: h }, { left: x2, top: y2, width: w2, height: h2 }); + } + export function isBrushedHighlightedDegree(doc: Doc) { if (Doc.IsHighlighted(doc)) { return 3; |