Add typed Kotlin rectangle area helper
ober
3b3c7f6affdebf20e02fc5bc160fbc08235b6b3e
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -427,7 +427,7 @@ (typed-kotlin-file "com/sfb/ssdreview/OcrGeometry.kt" (typed-library (com sfb ssdreview) - (export centerInside) + (export centerInside rectArea) (type Float32) (type FloatArray) (type Int32) @@ -444,7 +444,16 @@ (and (and (>= cx (float-array-ref rect (int32 0))) (<= cx (float-array-ref rect (int32 2)))) (and (>= cy (float-array-ref rect (int32 1))) - (<= cy (float-array-ref rect (int32 3)))))))))) + (<= cy (float-array-ref rect (int32 3)))))))) + (def (rectArea (rect : FloatArray)) : Float32 + (if (< (float-array-length rect) (int32 4)) + (float32 0.0) + (let ((width (- (float-array-ref rect (int32 2)) + (float-array-ref rect (int32 0)))) + (height (- (float-array-ref rect (int32 3)) + (float-array-ref rect (int32 1))))) + (* (if (< width (float32 0.0)) (float32 0.0) width) + (if (< height (float32 0.0)) (float32 0.0) height))))))) (typed-kotlin-file "com/sfb/ssdreview/UiTextHelpers.kt" (typed-library (com sfb ssdreview)