提交 75974d6c 编写于 作者: L lang

makePath auto calculate width or height

上级 0a328175
......@@ -59,7 +59,16 @@ define(function(require) {
*/
graphic.makePath = function (pathData, opts, rect) {
var path = pathTool.createFromString(pathData, opts);
var boundingRect = path.getBoundingRect();
if (rect) {
var aspect = boundingRect.width / boundingRect.height;
// Keep width / height ratio
if (isNaN(rect.width)) {
rect.width = rect.height * aspect;
}
if (isNaN(rect.height)) {
rect.height = rect.width / aspect;
}
this.resizePath(path, rect);
}
return path;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册