forked from tholman/generative-artistry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update favicon to be more friendly for high pixel density displays
- Loading branch information
1 parent
082236c
commit 380d27f
Showing
1 changed file
with
5 additions
and
6 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
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) | ||
})(); | ||
})(); |