Skip to content

Commit 107b574

Browse files
committed
[Editor] Three point color for entropy display
1 parent b4b8b8c commit 107b574

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Improvement ideas
22
## Editor
33
- [ ] Bug testing (I can't recall the issues we had previously)
4-
- [ ] Remove some of the options (or hide them better)
54
- [X] Fix animation for sidebar collapse
65
- [ ] Possibly: Resize listener on canvas container
76
- [ ] Move advanced options into a popover instead of the sidebar
@@ -12,6 +11,7 @@
1211
- [X] Pre-Annotation sources name (retrieved from CSVs)
1312
- [ ] ~~Word boxes rendering -- TODO: Do we really need this? (editor technically supports it, but handling code is missing)~~
1413
- [X] Tour
14+
- [ ] Gradients with three points
1515
- [ ] Completion handler improvements (soft complete (not all manually done), complete (all manually done))
1616
- [ ] ~~Indices rendering outside box if possible?~~
1717

src/editor/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ export const heatMapMinColor: Ref<Color> = ref( {
8484
'b': 0
8585
} );
8686

87+
export const heatMapMidColor: Ref<Color> = ref( {
88+
'r': 0,
89+
'g': 0,
90+
'b': 0
91+
} );
92+
8793
export const heatMapMaxColor: Ref<Color> = ref( {
8894
'r': 255,
8995
'g': 0,
@@ -92,6 +98,8 @@ export const heatMapMaxColor: Ref<Color> = ref( {
9298

9399
export const heatMapMinValue = ref( 0 );
94100

101+
export const heatMapMidValue = ref( 0.5 );
102+
95103
export const heatMapMaxValue = ref( 1 );
96104

97105
export const boundingBoxesOpacity = ref( 1 );

src/editor/render/fixations.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
fixationsOpacity,
1111
heatMapMaxColor,
1212
heatMapMaxValue,
13+
heatMapMidColor,
14+
heatMapMidValue,
1315
heatMapMinColor,
1416
heatMapMinValue,
1517
hoveredFixationColor,
@@ -90,14 +92,25 @@ export const fixationRenderer = ( fixationsCanvas: Ref<HTMLCanvasElement | null>
9092
const drawPoint = ( ctx: CanvasRenderingContext2D ) => {
9193
return ( fixation: EditorFixation, color: string, radius: number ) => {
9294
if ( renderFixationHeatMapInsteadOfDefaultColour.value && fixation.assigned === 'machine' && fixation.disagreement !== undefined ) {
93-
const percentage = fixation.disagreement / ( heatMapMaxValue.value - heatMapMinValue.value );
94-
const col: Color = {
95-
'r': heatMapMinColor.value.r + ( ( heatMapMaxColor.value.r - heatMapMinColor.value.r ) * percentage ),
96-
'g': heatMapMinColor.value.g + ( ( heatMapMaxColor.value.g - heatMapMinColor.value.g ) * percentage ),
97-
'b': heatMapMinColor.value.b + ( ( heatMapMaxColor.value.b - heatMapMinColor.value.b ) * percentage )
98-
};
99-
100-
ctx.fillStyle = `rgb( ${ col.r }, ${ col.g }, ${ col.b } )`;
95+
if ( fixation.disagreement < heatMapMidValue.value ) {
96+
const percentage = fixation.disagreement / ( heatMapMidValue.value - heatMapMinValue.value );
97+
const col: Color = {
98+
'r': heatMapMinColor.value.r + ( ( heatMapMidColor.value.r - heatMapMinColor.value.r ) * percentage ),
99+
'g': heatMapMinColor.value.g + ( ( heatMapMidColor.value.g - heatMapMinColor.value.g ) * percentage ),
100+
'b': heatMapMinColor.value.b + ( ( heatMapMidColor.value.b - heatMapMinColor.value.b ) * percentage )
101+
};
102+
103+
ctx.fillStyle = `rgb( ${ col.r }, ${ col.g }, ${ col.b } )`;
104+
} else {
105+
const percentage = fixation.disagreement / ( heatMapMaxValue.value - heatMapMidValue.value );
106+
const col: Color = {
107+
'r': heatMapMinColor.value.r + ( ( heatMapMaxColor.value.r - heatMapMidColor.value.r ) * percentage ),
108+
'g': heatMapMinColor.value.g + ( ( heatMapMaxColor.value.g - heatMapMidColor.value.g ) * percentage ),
109+
'b': heatMapMinColor.value.b + ( ( heatMapMaxColor.value.b - heatMapMidColor.value.b ) * percentage )
110+
};
111+
112+
ctx.fillStyle = `rgb( ${ col.r }, ${ col.g }, ${ col.b } )`;
113+
}
101114
} else {
102115
ctx.fillStyle = color;
103116
}

0 commit comments

Comments
 (0)