Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/QuantitativeSequenceRenderer/QuantitativeSequenceRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,34 @@ export default function rendererFactory(pluginManager: PluginManager) {
const scale = getScale(opts)

if (region.end - region.start > 5000) {
console.log('using super')
super.draw(ctx, props)
return
}

const toY = (n: number) => height - scale(n) + YSCALEBAR_LABEL_OFFSET
const toHeight = (n: number) => toY(originY) - toY(n)

console.log({ features })
ctx.textAlign = 'center'
ctx.font = 'bold 10px sans-serif'
for (const feature of features.values()) {
const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx)
const w = rightPx - leftPx + 0.4 // fudge factor for subpixel rendering
const score = feature.get('score') as number
const base = feature.get('base')
ctx.fillStyle = getColor(base)
ctx.fillRect(leftPx, toY(score), w, toHeight(score))
ctx.fillStyle = '#000'
if (1 / bpPerPx > 5) {
ctx.fillText(base, leftPx + (rightPx - leftPx) / 2, toY(score) - 2)
if (1 / bpPerPx < 5) {
ctx.fillRect(leftPx, toY(score), w, toHeight(score))
} else {
ctx.setTransform(
w / 10,
0,
0,
toHeight(score) / 4,
leftPx * 2 + (rightPx - leftPx),
height + toY(0) / 2 + YSCALEBAR_LABEL_OFFSET,
)

ctx.fillText(base, 0, 0)
}
}

Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@
resolved "https://registry.yarnpkg.com/@librpc/ee/-/ee-1.0.4.tgz#ce73a36279dc4cf93efa43f7e3564ec165947522"
integrity sha512-vhPlbRwAKQC80h0k74tsOkMKIidZtqlFSOHRzCvC8n7Va9rzMDwpG26Pm84dAt0ZuGK0g1UEfPzxDiYo9ZQBrg==

"@librpc/web@github:rbuels/librpc-web#737bb9706762a52a87169a12c9b59fb241febab0":
"@librpc/web@rbuels/librpc-web#737bb9706762a52a87169a12c9b59fb241febab0":
version "1.1.0"
resolved "https://codeload.github.com/rbuels/librpc-web/tar.gz/737bb9706762a52a87169a12c9b59fb241febab0"
dependencies:
Expand Down