Flags with Polygons

From ProgZoo
Revision as of 13:20, 8 August 2021 by Andr3w (talk | contribs) (Created page with "<pre id='shellbody'> <div style='background:silver;padding:5px'> <canvas id='usr' width=--snippet-w-- height=--snippet-h--></canvas> <canvas id='ans' width=--snippet-w-- heigh...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
<div style='background:silver;padding:5px'>
<canvas id='usr' width=--snippet-w-- height=--snippet-h--></canvas>
<canvas id='ans' width=--snippet-w-- height=--snippet-h-- style='display:none'></canvas>
</div>
--snippet-usr--
drawFlag(document.getElementById('usr').getContext('2d'));
(()=>{
  --snippet-ans--
  drawFlag(document.getElementById('ans').getContext('2d'));
})();
let [a,b] = ['usr','ans']
    .map(id=>document.getElementById(id))
    .map(elem=>elem.getContext('2d').getImageData(0,0,elem.width,elem.height))
let diff = a.data.map((v,i) => v===b.data[i]?1:0).reduce((acc,v)=>acc+v,0)*100/a.data.length;
let fb = document.createElement('div');
fb.innerText = `Score: ${diff.toFixed(1)}`;
document.body.appendChild(fb);
fetch(`/reportProgress.php?uid=--snippet-uid--&qid=--snippet-qid--&score=${diff}`);

Napier

Flagnapier.png

function drawFlag(ctx)
{
}
function drawFlag(ctx)
{
}

The Bahamas

Flagbahamas.png

function drawFlag(ctx)
{
}
function drawFlag(ctx)
{
}

Jamaica

Flagjamaica.png

function drawFlag(ctx)
{
}
function drawFlag(ctx)
{
}

Seychelles

Flagseychelles.png

function drawFlag(ctx)
{
}
function drawFlag(ctx)
{
}