Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created February 3, 2013 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enjalot/4700584 to your computer and use it in GitHub Desktop.
Save enjalot/4700584 to your computer and use it in GitHub Desktop.
prototype: box json
{"description":"prototype: box json","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"test.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"fullscreen":false,"thumbnail":"http://i.imgur.com/KgXdncn.png"}
var test = tributary.test;
console.log(test);
var x = test.x;
var y = test.y;
var w = test.width;
var h = test.height;
var svg = d3.select("svg");
svg.append("rect")
.attr(test);
var zoom = d3.behavior.zoom()
.on("zoom", function() {
var scale = d3.event.scale;
var translate = d3.event.translate;
//console.log(scale, translate);
test.x = x + translate[0];
test.y = y + translate[1];
test.width = w * scale;
test.height = h * scale;
d3.select("rect").attr(test);
updateTest();
})
svg.call(zoom);
function updateTest() {
var cm = tributary.getCodeEditor("test.json");
cm.setValue(JSON.stringify(test));
}
rect {
fill: #CA6262;
stroke: #000000;
stroke-width: 3;
}
{"x":91.20585789736927,"y":273.0809537877534,"width":287.9862637029376,"height":287.9862637029376,"rx":5,"ry":5}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment