in client/client/modules/render/tracks/gene/internal/renderer/features/drawing/transcriptFeatureRenderer.js [86:201]
_renderNonEmptyBlock(opts) {
const {viewport, graphics, hoveredGraphics, block, centeredPositionY} = opts;
const shouldDrawAminoacid = this._aminoacidFeatureRenderer !== null ? this._aminoacidFeatureRenderer.shouldDrawAminoacids(viewport) : false;
const pixelsInBp = viewport.factor;
const blockPxStart = Math.max(viewport.project.brushBP2pixel(block.startIndex), -viewport.canvasSize) - pixelsInBp / 2;
const blockPxEnd = Math.min(viewport.project.brushBP2pixel(block.endIndex), 2 * viewport.canvasSize) + pixelsInBp / 2;
const white = 0xFFFFFF;
const height = this.config.transcript.height;
graphics.lineStyle(0, white, 0);
hoveredGraphics.lineStyle(0, white, 0);
for (let j = 0; j < block.items.length; j++) {
const blockItem = block.items[j];
const {
fill,
hoveredFill,
shouldDrawStrand,
strandFill,
hoveredStrandFill,
shouldFillBlock
} = this._getBlockDrawingConfig(blockItem, shouldDrawAminoacid);
const blockItemPxStart = Math.max(viewport.project.brushBP2pixel(blockItem.startIndex), -viewport.canvasSize) - pixelsInBp / 2;
const blockItemPxEnd = Math.min(viewport.project.brushBP2pixel(blockItem.endIndex), 2 * viewport.canvasSize) + pixelsInBp / 2;
if (blockItemPxStart > blockItemPxEnd) {
continue;
}
if (shouldFillBlock) {
graphics
.beginFill(fill, 1)
.drawRect(
blockItemPxStart,
centeredPositionY - height / 2,
blockItemPxEnd - blockItemPxStart,
height)
.endFill();
hoveredGraphics
.beginFill(hoveredFill, 1)
.drawRect(
blockItemPxStart,
centeredPositionY - height / 2,
blockItemPxEnd - blockItemPxStart,
height)
.endFill();
this.updateTextureCoordinates(
{
x: blockItemPxStart,
y: centeredPositionY - height / 2
});
}
if (shouldDrawStrand) {
drawStrandDirection(
block.strand,
{
centerY: centeredPositionY,
height: height,
width: blockItemPxEnd - blockItemPxStart,
x: blockItemPxStart
},
graphics,
strandFill,
this.config.transcript.features.strand.arrow,
1,
::this.updateTextureCoordinates
);
drawStrandDirection(
block.strand,
{
centerY: centeredPositionY,
height: height,
width: blockItemPxEnd - blockItemPxStart,
x: blockItemPxStart
},
hoveredGraphics,
hoveredStrandFill,
this.config.transcript.features.strand.arrow,
1,
::this.updateTextureCoordinates
);
}
if (!this.collapsedMode && blockItem.attributes && blockItem.attributes.exon_number) {
this.registerFeaturePosition(
{
exonNumber: blockItem.attributes.exon_number,
feature: 'exon'
},
{
x1: blockItemPxStart,
x2: blockItemPxEnd,
y1: centeredPositionY - height / 2,
y2: centeredPositionY + height / 2
},
null,
FEATURE_INDEX_EXON);
}
}
graphics
.lineStyle(this.config.transcript.features.border.thickness, this.config.transcript.features.border.color, 1)
.drawRect(
blockPxStart,
centeredPositionY - height / 2,
blockPxEnd - blockPxStart,
height
);
hoveredGraphics
.lineStyle(this.config.transcript.features.border.thickness, ColorProcessor.darkenColor(this.config.transcript.features.border.color), 1)
.drawRect(
blockPxStart,
centeredPositionY - height / 2,
blockPxEnd - blockPxStart,
height
);
this.updateTextureCoordinates(
{
x: blockPxStart,
y: centeredPositionY - height / 2
});
}