From feb1572ab1f196c7c7f60209c53dbf65c8d67142 Mon Sep 17 00:00:00 2001 From: Shivang Dwivedi <83856109+studentshivang@users.noreply.github.com> Date: Thu, 18 May 2023 23:06:53 +0530 Subject: [PATCH] Fix horizontal flip functionality for Hi-C display (#3667) This commit intends to add functionality to the "Horizontally Flip" Feature in the Hamburger Menu. Detailed discussion can be found in issue #3460 (https://github.com/GMOD/jbrowse-components/issues/3460) --- plugins/hic/src/HicRenderer/HicRenderer.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/hic/src/HicRenderer/HicRenderer.tsx b/plugins/hic/src/HicRenderer/HicRenderer.tsx index c8c9d9a15c..aa7b88306b 100644 --- a/plugins/hic/src/HicRenderer/HicRenderer.tsx +++ b/plugins/hic/src/HicRenderer/HicRenderer.tsx @@ -61,7 +61,9 @@ export default class HicRenderer extends ServerSideRendererType { resolution, sessionId, adapterConfig, + regions, } = props + const [region] = regions const { dataAdapter } = await getAdapter( this.pluginManager, sessionId, @@ -87,6 +89,14 @@ export default class HicRenderer extends ServerSideRendererType { maxBin = Math.max(Math.max(bin1, bin2), maxBin) } await abortBreakPoint(signal) + function horizontallyFlip() { + ctx.scale(-1, 1) + const width = (region.end - region.start) / bpPerPx + ctx.translate(-width, 0) + } + if (region.reversed === true) { + horizontallyFlip() + } ctx.rotate(-Math.PI / 4) let start = Date.now() for (let i = 0; i < features.length; i++) {