mirror of
https://github.com/seigler/dash-visualizer
synced 2025-07-27 01:36:10 +00:00
🐛 choose color scheme based on LEAST sig places of block hash
This commit is contained in:
parent
e37fa5e72e
commit
a073e2d334
1 changed files with 6 additions and 5 deletions
|
@ -13,14 +13,15 @@ var App = {
|
||||||
var currentBlock = document.createElement('div');
|
var currentBlock = document.createElement('div');
|
||||||
currentBlock.className = 'block';
|
currentBlock.className = 'block';
|
||||||
blockList.appendChild(currentBlock);
|
blockList.appendChild(currentBlock);
|
||||||
|
var blockColors = ['000000'];
|
||||||
var prevBlockHash;
|
var prevBlockHash;
|
||||||
await fetch('https://insight.dash.org/api/status?q=getLastBlockHash')
|
|
||||||
|
fetch('https://insight.dash.org/api/status?q=getLastBlockHash')
|
||||||
.then(resp => resp.json())
|
.then(resp => resp.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
prevBlockHash = data.lastblockhash;
|
prevBlockHash = data.lastblockhash;
|
||||||
|
blockColors = generateColors(prevBlockHash);
|
||||||
});
|
});
|
||||||
var blockColors = generateColors(prevBlockHash);
|
|
||||||
|
|
||||||
const psInputSatoshis = [
|
const psInputSatoshis = [
|
||||||
1000010000,
|
1000010000,
|
||||||
|
@ -72,10 +73,10 @@ var App = {
|
||||||
const schemeTypes = ['mono', 'contrast', 'triade', 'tetrade', 'analogic'];
|
const schemeTypes = ['mono', 'contrast', 'triade', 'tetrade', 'analogic'];
|
||||||
var blockColorScheme = new ColorScheme();
|
var blockColorScheme = new ColorScheme();
|
||||||
blockColorScheme.from_hue(
|
blockColorScheme.from_hue(
|
||||||
Math.floor(parseInt(prevBlockHash.slice(0, 3), 16) / 4096 * 360)
|
Math.floor(parseInt(prevBlockHash.slice(-3), 16) / 4096 * 360)
|
||||||
).scheme(
|
).scheme(
|
||||||
schemeTypes[
|
schemeTypes[
|
||||||
Math.floor(parseInt(prevBlockHash.slice(3, 5), 16) / 256 * schemeTypes.length)
|
Math.floor(parseInt(prevBlockHash.slice(-5, -3), 16) / 256 * schemeTypes.length)
|
||||||
]
|
]
|
||||||
).distance(0.75);
|
).distance(0.75);
|
||||||
return blockColorScheme.colors();
|
return blockColorScheme.colors();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue