You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.7 KiB

<title>JavaScript <=> PaperScript example</title>
<code mode="text/html">
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="paper.js"></script>
<script type="text/javascript" src="truchet.js"></script>
<script type="text/javascript">
window.onload = function() {
paper.install(window);
paper.setup(document.getElementById('canvas'));
/*
var ret = draw_tile('x', new Point(200, 200), 100, false);
ret[0].scale(3);
ret[1].scale(3);
ret[1].translate(new Size(0, 400));
ret[0].fullySelected = true;
ret[1].fullySelected = true;
return;
*/
var tiles = gen_tiles(0, 3, 5);
var grp = new Group();
var dtiles = draw_tiles(tiles, new paper.Point(0, 0));
console.log(dtiles);
//dtiles[0].fillColor = 'black';
// dtiles[1].fillColor = null;
//grp.addChildren(dtiles[1]);
//grp.addChildren(dtiles[0]);
dtiles[0].fillColor = 'black';
dtiles[0].strokeColor = null;
grp.addChild(dtiles[0]); // fg
//grp.addChild(dtiles[1]); // bg
grp.addChildren(dtiles[2]); // debug
grp.translate(new Point(400, 400));
grp.scale(800);
//grp.fullySelected = true;
/*
grp.fillColor = 'black';
grp.strokeColor = null;
*/
/*
document.getElementById('download-svg').addEventListener('click', function() {
var svgdata = 'data:image/svg+xml;utf8,' + encodeURIComponent(get_svg());
var a = document.createElement('a');
a.download = 'export.svg';
a.href = svgdata;
document.body.appendChild(a);
a.click();
});
*/
}
</script>
</head>
<body>
<canvas id="canvas" style="width: 900px; height: 900px;" resize></canvas>
</body>
</html>