MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / centerGraphic

Function centerGraphic

libs/echarts/echarts-en.simple.js:16997–17018  ·  view source on GitHub ↗

* Get position of centered element in bounding box. * * @param {Object} rect element local bounding box * @param {Object} boundingRect constraint bounding box * @return {Object} element position containing x, y, width, and height

(rect, boundingRect)

Source from the content-addressed store, hash-verified

16995 * @return {Object} element position containing x, y, width, and height
16996 */
16997function centerGraphic(rect, boundingRect) {
16998 // Set rect to center, keep width / height ratio.
16999 var aspect = boundingRect.width / boundingRect.height;
17000 var width = rect.height * aspect;
17001 var height;
17002 if (width <= rect.width) {
17003 height = rect.height;
17004 }
17005 else {
17006 width = rect.width;
17007 height = width / aspect;
17008 }
17009 var cx = rect.x + rect.width / 2;
17010 var cy = rect.y + rect.height / 2;
17011
17012 return {
17013 x: cx - width / 2,
17014 y: cy - height / 2,
17015 width: width,
17016 height: height
17017 };
17018}
17019
17020var mergePath = mergePath$1;
17021

Callers 2

makePathFunction · 0.70
makeImageFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected