1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>包围盒计算测试</title>
<script src="lib/config.js"></script>
</head>
<body>
<div id="Main"></div>
</body>
<script type="importmap">
{
"imports": {
"zrender/": "../",
"tslib": "../node_modules/tslib/tslib.es6.js"
}
}
</script>
<script type="module">
import PathProxy from 'zrender/lib/core/PathProxy.js'
var canvas = document.createElement('canvas')
document.getElementById("Main").appendChild(canvas);
canvas.width = 1024;
canvas.height = 600;
var ctx = canvas.getContext("2d");
var path = new PathProxy();
path.setContext(ctx);
path.beginPath();
path.moveTo(20, 20);
path.bezierCurveTo(100, 0, -100, 100, 100, 100);
path.quadraticCurveTo(400, 10, 200, 200);
path.arc(200, 200, 50, 1, 10, true);
path.stroke(ctx);
var bb = path.getBoundingRect();
ctx.beginPath();
ctx.strokeRect(bb.x, bb.y, bb.width, bb.height);
</script>
</html>
|