Skip to content

Commit

Permalink
update favicon to be more friendly for high pixel density displays
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrugile committed Aug 24, 2018
1 parent 082236c commit 380d27f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions static/js/favicon.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
(function () {
// Create canvas & context
var canvas = document.createElement('canvas')
var size = 20
var size = 32
canvas.height = canvas.width = size
var context = canvas.getContext('2d')
context.lineWidth = 2

// Favicon element
var link = document.createElement('link')
link.rel = 'icon'
link.type = 'image/png'

// Loop through and draw random diagonals
var step = 4
var step = 8
for( var x = 0; x < size; x += step) {
for( var y = 0; y < size; y+= step ) {
var leftToRight = Math.random() >= 0.5

if( leftToRight ) {
context.moveTo(x, y)
context.lineTo(x + step, y + step)
} else {
context.moveTo(x + step, y)
context.lineTo(x, y + step)
}

context.stroke()
}
}
context.stroke()

// Save to favicon and append to page
link.href = canvas.toDataURL('image/png')
document.head.appendChild(link)
})();
})();

0 comments on commit 380d27f

Please sign in to comment.