Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2015 18:06
Show Gist options
  • Save anonymous/7f358d48be72d6de108b to your computer and use it in GitHub Desktop.
Save anonymous/7f358d48be72d6de108b to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yelehizudo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
body, canvas {
width: 100%;
height: 500px;
}
</style>
</head>
<body>
<canvas></canvas>
<script id="jsbin-javascript">
var canvas = document.querySelector('canvas');
var p = canvas.parentElement;
var w = p.offsetWidth;
var h = p.offsetHeight;
canvas.width = w;
canvas.height = h;
var ctx = canvas.getContext("2d");
ctx.fillStyle = 'rgba(100,200,255,0.4)';
ctx.fillRect(50,-50,100,100);
ctx.fillStyle = 'rgba(20,20,20,0.1)';
ctx.fillRect(75,50,100,-100);
ctx.strokeRect(75,50,100,-100);
ctx.fillStyle = 'rgba(100,255,200,0.4)';
ctx.fillRect(100,-50,100,100);
ctx.fillStyle = 'rgba(100,200,255,0.4)';
ctx.fillRect(-50,150,100,100);
ctx.fillStyle = 'rgba(20,20,20,0.1)';
ctx.fillRect(50,175,-100,100);
ctx.strokeRect(50,175,-100,100);
ctx.fillStyle = 'rgba(100,255,200,0.4)';
ctx.fillRect(-50,200,100,100);
</script>
<script id="jsbin-source-css" type="text/css">body, canvas {
width: 100%;
height: 500px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">var canvas = document.querySelector('canvas');
var p = canvas.parentElement;
var w = p.offsetWidth;
var h = p.offsetHeight;
canvas.width = w;
canvas.height = h;
var ctx = canvas.getContext("2d");
ctx.fillStyle = 'rgba(100,200,255,0.4)';
ctx.fillRect(50,-50,100,100);
ctx.fillStyle = 'rgba(20,20,20,0.1)';
ctx.fillRect(75,50,100,-100);
ctx.strokeRect(75,50,100,-100);
ctx.fillStyle = 'rgba(100,255,200,0.4)';
ctx.fillRect(100,-50,100,100);
ctx.fillStyle = 'rgba(100,200,255,0.4)';
ctx.fillRect(-50,150,100,100);
ctx.fillStyle = 'rgba(20,20,20,0.1)';
ctx.fillRect(50,175,-100,100);
ctx.strokeRect(50,175,-100,100);
ctx.fillStyle = 'rgba(100,255,200,0.4)';
ctx.fillRect(-50,200,100,100);
</script></body>
</html>
body, canvas {
width: 100%;
height: 500px;
}
var canvas = document.querySelector('canvas');
var p = canvas.parentElement;
var w = p.offsetWidth;
var h = p.offsetHeight;
canvas.width = w;
canvas.height = h;
var ctx = canvas.getContext("2d");
ctx.fillStyle = 'rgba(100,200,255,0.4)';
ctx.fillRect(50,-50,100,100);
ctx.fillStyle = 'rgba(20,20,20,0.1)';
ctx.fillRect(75,50,100,-100);
ctx.strokeRect(75,50,100,-100);
ctx.fillStyle = 'rgba(100,255,200,0.4)';
ctx.fillRect(100,-50,100,100);
ctx.fillStyle = 'rgba(100,200,255,0.4)';
ctx.fillRect(-50,150,100,100);
ctx.fillStyle = 'rgba(20,20,20,0.1)';
ctx.fillRect(50,175,-100,100);
ctx.strokeRect(50,175,-100,100);
ctx.fillStyle = 'rgba(100,255,200,0.4)';
ctx.fillRect(-50,200,100,100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment