UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

30 lines (29 loc) 1.57 kB
import { s as Y, am as A, R as G, u as b } from "./JBrowsePanel-uJIA-L6s.js"; const W = 0.3, v = 2; function q(o, w) { const { features: C, regions: S, bpPerPx: f, scaleOpts: p, height: y, ticks: { values: M }, displayCrossHatches: E, colorCallback: I, config: N, offset: a = 0, stopToken: F } = w, l = S[0], H = (l.end - l.start) / f, r = y - a * 2, g = Y.readConfObject(N, "clipColor"), h = A({ ...p, range: [0, r] }), u = h.domain(), R = u[0], j = u[1], s = (e) => b.clamp(r - (h(e) || 0), 0, r) + a; let c, d = Number.NEGATIVE_INFINITY; const T = []; let m = performance.now(); for (const e of C.values()) { performance.now() - m > 400 && (G.checkStopToken(F), m = performance.now()); const [t, i] = b.featureSpanPx(e, l, f); (Math.floor(t) !== Math.floor(d) || i - t > 1) && (T.push(e), d = t); const n = e.get("score"), L = n < R, O = n > j, k = i - t + W, V = I(e, n); o.beginPath(), o.strokeStyle = V; const P = c !== void 0 ? c : n; l.reversed ? (o.moveTo(i, s(P)), o.lineTo(i, s(n)), o.lineTo(t, s(n))) : (o.moveTo(t, s(P)), o.lineTo(t, s(n)), o.lineTo(i, s(n))), o.stroke(), c = n, O ? (o.fillStyle = g, o.fillRect(t, a, k, v)) : L && p.scaleType !== "log" && (o.fillStyle = g, o.fillRect(t, r - v, k, r)); } if (E) { o.lineWidth = 1, o.strokeStyle = "rgba(200,200,200,0.5)"; for (const e of M) o.beginPath(), o.moveTo(0, Math.round(s(e))), o.lineTo(H, Math.round(s(e))), o.stroke(); } return { reducedFeatures: T }; } export { q as drawLine }; //# sourceMappingURL=drawLine-Br22xpT0.js.map