<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body style="background-color: #222">
<div id="holder" style="background-color:#222">
</div>
</body>
</html>
var container = d3.select('#holder');
var svg = container.append("svg").attr("width", 1000).attr("height", 1000);
// svg.append("circle")
// .attr("cx", 200)
// .attr("cy", 200)
// .attr("r", 50);
var x = 0;
var y = 0;
var pathString = '';
var x1, x2, x3, x4;
var y1, y2, y3, y4;
var flip = true;
for (var j = 0; j < 30; j++) {
for (var i = 0; i < 30; i++) {
x1 = x + 0;
y1 = y + 15;
x2 = x + 5;
y2 = y + 0;
x3 = x + 10;
y3 = y + 15;
x4 = x + 5;
y4 = y + 30;
x = x + 10;
pathString = 'M ' + x1 + ',' + y1 + " L " + x2 + "," + y2 + " L " + x3 + "," + y3 + " L " + x4 + "," + y4 + " Z";
if (Math.random() > 0.9) {
svg.append("path")
.style("fill", "#5AF")
.attr("stroke", "none")
.attr("d", pathString);
}
else if (Math.random() > 0.5) {
svg.append("path")
.style("fill", "#246")
.attr("stroke", "none")
.attr("d", pathString);
}
else {
svg.append("path")
.style("fill", "#369")
.attr("stroke", "none")
.attr("d", pathString);
}
}
y = y + 30;
x = 0;
}
x = 5;
y = 15;
for (var j = 0; j < 30; j++) {
for (var i = 0; i < 30; i++) {
x1 = x + 0;
y1 = y + 15;
x2 = x + 5;
y2 = y + 0;
x3 = x + 10;
y3 = y + 15;
x4 = x + 5;
y4 = y + 30;
x = x + 10;
pathString = 'M ' + x1 + ',' + y1 + " L " + x2 + "," + y2 + " L " + x3 + "," + y3 + " L " + x4 + "," + y4 + " Z";
if (Math.random() > 0.9) {
svg.append("path")
.style("fill", "#5AF")
.attr("stroke", "none")
.attr("d", pathString);
}
else if (Math.random() > 0.5) {
svg.append("path")
.style("fill", "#246")
.attr("stroke", "none")
.attr("d", pathString);
}
else {
svg.append("path")
.style("fill", "#369")
.attr("stroke", "none")
.attr("d", pathString);
}
flip = !flip;
}
y = y + 30;
x = 5;
}
// .attr("x1",0).attr("y1",15)
// .attr("x2",5).attr("y2",0)
// .attr("x3",10).attr("y3",15)
// .attr("x4",5).attr("y4",30)
// .attr("stroke-width", 2)
// .attr("stroke", "black");
$("svg").html($("svg").html()); //convince the browser that there's some svgs goin' down
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |