Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save/load graph JSON #63

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
31 changes: 31 additions & 0 deletions demos/import-graph/import-graph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
fetch('zdog.json')
.then(function( res ) {
return res.json();
})
.then(function(model) {
// ----- variables ----- //
var sceneSize = 100;
var TAU = Zdog.TAU;
var initRotate = { x: 20/360 * TAU, y: -50/360 * TAU };

// ----- model ----- //
var illo = new Zdog.Illustration({
element: '.illo',
rotate: initRotate,
dragRotate: true,
resize: 'fullscreen',
importGraph: model,
onResize: function( width, height ) {
this.zoom = Math.floor( Math.min( width, height ) * 2 / sceneSize ) / 2;
},
});

// ----- animate ----- //

function animate() {
illo.updateRenderGraph();
requestAnimationFrame(animate);
}

animate();
});
47 changes: 47 additions & 0 deletions demos/import-graph/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />

<title>Import graph</title>

<style>
html { height: 100%; }

body {
min-height: 100%;
margin: 0;
}

.illo {
display: block;
width: 100%;
height: 100%;
cursor: move;
background: #FDB;
}
</style>

</head>
<body>

<div class="container">
<canvas class="illo"></canvas>
</div>

<script src="../../js/boilerplate.js"></script>
<script src="../../js/canvas-renderer.js"></script>
<script src="../../js/vector.js"></script>
<script src="../../js/anchor.js"></script>
<script src="../../js/path-command.js"></script>
<script src="../../js/shape.js"></script>
<script src="../../js/ellipse.js"></script>
<script src="../../js/rect.js"></script>
<script src="../../js/group.js"></script>
<script src="../../js/dragger.js"></script>
<script src="../../js/illustration.js"></script>
<script src="import-graph.js"></script>

</body>
</html>
Loading