Skip to content

Instantly share code, notes, and snippets.

@serverwentdown
Created September 1, 2014 12:53
Show Gist options
  • Save serverwentdown/c6b8f1518abc23be975f to your computer and use it in GitHub Desktop.
Save serverwentdown/c6b8f1518abc23be975f to your computer and use it in GitHub Desktop.
Derping around
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>infocomm</title>
<style>
* {
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<canvas id="c" width="1366" height="768">
You gotz no canvas.
</canvas>
<script>
var width = 1366;
var height = 768;
var spacing = 32;
var weight = 2;
var blur = 30;
var strokecolor = "#3a3";
var shadowcolor = "#0d0";
var offset = {
x: -3,
y: -3
};
var can = document.getElementById("c");
if (can.getContext) {
var ctx = can.getContext("2d");
ctx.strokeStyle = strokecolor;
ctx.lineWidth = weight;
ctx.shadowBlur = blur;
ctx.shadowColor = shadowcolor;
ctx.fillStyle = "#000";
ctx.fillRect(0, 0, width, height);
ctx.fillStyle = "transparent";
for (var i = 0; i < (width / spacing) + 1; i++) {
var start = {
x: Math.floor(i * spacing) + offset.x,
y: 0
};
var end = {
x: start.x,
y: height
};
console.log(start, end);
ctx.beginPath();
ctx.moveTo(start.x, start.y);
ctx.lineTo(end.x, end.y);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(start.x, start.y);
ctx.lineTo(end.x, end.y);
ctx.stroke();
}
for (var i = 0; i < (height / spacing) + 1; i++) {
var start = {
x: 0,
y: Math.floor(i * spacing) + offset.y
};
var end = {
x: width,
y: start.y
};
// console.log(start, end);
ctx.beginPath();
ctx.moveTo(start.x, start.y);
ctx.lineTo(end.x, end.y);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(start.x, start.y);
ctx.lineTo(end.x, end.y);
ctx.stroke();
}
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillStyle = "#fff";
ctx.font = "700" + " " + Math.floor(height / 4) + "px" + " " + "'Ubuntu Mono'";
ctx.fillText("infocomm", Math.floor(width / 2), Math.floor(height / 2) - Math.floor(height / 32));
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment