Skip to content

Instantly share code, notes, and snippets.

@tonyhschu
Created July 10, 2016 20:22
Show Gist options
  • Save tonyhschu/9724533f16c817142e91abe72e65f93f to your computer and use it in GitHub Desktop.
Save tonyhschu/9724533f16c817142e91abe72e65f93f to your computer and use it in GitHub Desktop.
fresh block
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width:100%; height: 100% }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see!
var points = [[608,814],[609,814],[612,814],[615,814],[608,815],[616,815],[608,816],[612,816],[615,816],[608,817],[613,817],[614,817],[615,817],[617,817],[618,817],[619,817],[605,818],[608,818],[612,818],[619,818],[620,818],[604,819],[605,819],[606,819],[607,819],[608,819],[609,819],[611,819],[614,819],[620,819],[621,819],[607,820],[608,820],[609,820],[611,820],[614,820],[615,820],[621,820],[604,821],[605,821],[606,821],[607,821],[611,821],[612,821],[613,821],[614,821],[619,821],[620,821],[621,821],[622,821],[623,821],[601,822],[603,822],[611,822],[613,822],[614,822],[618,822],[619,822],[620,822],[600,823],[601,823],[604,823],[605,823],[606,823],[607,823],[609,823],[610,823],[613,823],[615,823],[616,823],[617,823],[618,823],[619,823],[620,823],[621,823],[622,823],[623,823],[624,823],[599,824],[600,824],[601,824],[602,824],[603,824],[604,824],[605,824],[610,824],[613,824],[614,824],[616,824],[617,824],[620,824],[622,824],[599,825],[600,825],[601,825],[602,825],[603,825],[605,825],[608,825],[611,825],[615,825],[617,825],[622,825],[626,825],[597,826],[599,826],[600,826],[601,826],[602,826],[605,826],[607,826],[608,826],[611,826],[612,826],[614,826],[615,826],[616,826],[617,826],[618,826],[622,826],[623,826],[624,826],[625,826],[596,827],[601,827],[602,827],[605,827],[607,827],[608,827],[611,827],[612,827],[614,827],[616,827],[617,827],[618,827],[622,827],[625,827],[626,827],[627,827],[600,828],[601,828],[606,828],[607,828],[608,828],[609,828],[611,828],[613,828],[615,828],[628,828],[629,828],[597,829],[598,829],[599,829],[601,829],[602,829],[603,829],[606,829],[608,829],[610,829],[613,829],[626,829],[627,829],[629,829],[600,830],[601,830],[602,830],[603,830],[604,830],[606,830],[613,830],[616,830],[617,830],[618,830],[619,830],[600,831],[602,831],[605,831],[606,831],[613,831],[616,831],[621,831],[622,831],[626,831],[627,831],[602,832],[606,832],[624,832],[610,839],[611,839],[615,842]]
var pointsIndex = {}
points.forEach(function(p) {
pointsIndex[(p[0] + '_' + p[1])] = p
})
var surroundingPoints = function(p) {
return [
(p[0] - 1) + '_' + (p[1] - 1),
(p[0]) + '_' + (p[1] - 1),
(p[0] + 1) + '_' + (p[1] - 1),
(p[0] - 1) + '_' + (p[1]),
(p[0] + 1) + '_' + (p[1]),
(p[0] - 1) + '_' + (p[1] + 1),
(p[0]) + '_' + (p[1] + 1),
(p[0] + 1) + '_' + (p[1] + 1),
]
}
edgePoints = points.filter(function(p) {
surroundings = surroundingPoints(p)
return surroundings.some(function(s) {
return typeof pointsIndex[s] !== 'undefined'
})
})
console.log(points.length, edgePoints)
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment