@osdlabel/decoration
v0.21.0
Published
Declarative annotation decorations (labels, measurements, connector lines) and calibrated geometry math for osdlabel.
Readme
@osdlabel/decoration
Declarative annotation decorations (text labels, computed measurements, connector lines) and calibrated geometry math for osdlabel, a web-based image annotation library for gigapixel/DZI images.
Decorations are a pure derivation of annotation state — they are never
serialized, and they are recomputed whenever the underlying annotations change.
This package defines the data model and provider contract; the rendering happens
in @osdlabel/fabric-osd. Zero framework dependencies. Depends on
@osdlabel/annotation, @osdlabel/geometry, and @osdlabel/viewer-api.
Installation
npm install @osdlabel/decorationWhat's inside
Decorationdiscriminated union —TextDecoration(supportszIndex),LineDecoration, andDomDecorationDecorationProvidercontract +composeProviders,DecorationContext- Built-in providers:
createMeasurementProvider,createLabelProvider,createDistanceProvider withSelectionEmphasis— opt-in style/z-index elevation for the selected annotation's decorations- Measurements:
Measurement,measureDistance,measureLength,measurePerimeter(per-axis, correct on anisotropic images),toPhysicalLength,toPhysicalArea,formatMeasurement - Geometry math —
area,perimeter,length,radius,distance,centroid,midpoint,boundingBox,circleToBoundingRectangle— now lives in@osdlabel/geometryand is re-exported here unchanged
Usage
import {
createLabelProvider,
createMeasurementProvider,
composeProviders,
} from '@osdlabel/decoration';
// composeProviders takes an array; createMeasurementProvider needs an options
// object saying which measurements to render (all flags default to false).
const providers = composeProviders([
createLabelProvider(),
createMeasurementProvider({ area: true, perimeter: true, length: true, radius: true }),
]);License
BSD-3-Clause. Part of the osdlabel monorepo.
