This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from cBioPortal/draw-arrays-instanced
Optimizations
- Loading branch information
Showing
17 changed files
with
767 additions
and
468 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,40 @@ | ||
export default function extractrgba(str:string) { | ||
let ret = [0, 0, 0, 1]; | ||
import { fastParseInt16 } from "./utils"; | ||
import {RGBAColor} from "./oncoprintruleset"; | ||
|
||
export default function extractrgba(str:string):RGBAColor { | ||
if (str[0] === "#") { | ||
// hex, convert to rgba | ||
const r = parseInt(str[1] + str[2], 16); | ||
const g = parseInt(str[3] + str[4], 16); | ||
const b = parseInt(str[5] + str[6], 16); | ||
str = 'rgba('+r+','+g+','+b+',1)'; | ||
return hexToRGBA(str); | ||
} | ||
const match = str.match(/^[\s]*rgba\([\s]*([0-9.]+)[\s]*,[\s]*([0-9.]+)[\s]*,[\s]*([0-9.]+)[\s]*,[\s]*([0-9.]+)[\s]*\)[\s]*$/); | ||
if (match && match.length === 5) { | ||
ret = [parseFloat(match[1]) / 255, | ||
return [parseFloat(match[1]) / 255, | ||
parseFloat(match[2]) / 255, | ||
parseFloat(match[3]) / 255, | ||
parseFloat(match[4])]; | ||
} | ||
return ret; | ||
throw `could not extract rgba from ${str}`; | ||
}; | ||
|
||
export function hexToRGBA(str:string):RGBAColor { | ||
const r = fastParseInt16(str[1] + str[2]); | ||
const g = fastParseInt16(str[3] + str[4]); | ||
const b = fastParseInt16(str[5] + str[6]); | ||
return [r,g,b,1]; | ||
} | ||
|
||
export function rgbaToHex(rgba:RGBAColor):string { | ||
let hexR = rgba[0].toString(16); | ||
let hexG = rgba[1].toString(16); | ||
let hexB = rgba[2].toString(16); | ||
if (hexR.length === 1) { | ||
hexR = '0' + hexR; | ||
} | ||
if (hexG.length === 1) { | ||
hexG = '0' + hexG; | ||
} | ||
if (hexB.length === 1) { | ||
hexB = '0' + hexB; | ||
} | ||
return `#${hexR}${hexG}${hexB}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.